Skip to content

On custom template, Handlebars regex causes Metalsmith to erroneously target non-handlebars files #167

Closed
@enlore

Description

@enlore

Hey all. I'm on my way to a hackathon so I forked the vuejs/browserify template and threw some css and js files in there to make a simple Vue/Material Design Lite project template. The template generation process barfs, as follows:

mqi7918 at CORPMQI7918MB.local in [~/projects/code/access-to-law]   
14:48:18 › vue --version
2.3.1

mqi7918 at CORPMQI7918MB.local in [~/projects/code/access-to-law]   
14:46:10 › vue init enlore/browserify-mdl my-project

# a bunch of crap cut for brevity

/usr/local/lib/node_modules/vue-cli/bin/vue-init:165
          throw err
          ^

Error: Parse error on line 420:
... * * @typedef {{ *   constructor: Fun
--------------------^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'
    at Object.parseError (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:267:19)
    at Object.parse (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:336:30)
    at HandlebarsEnvironment.parse (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:46:43)
    at compileInput (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:514:19)
    at ret (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:523:18)
    at /usr/local/lib/node_modules/vue-cli/node_modules/consolidate/lib/consolidate.js:734:16
    at /usr/local/lib/node_modules/vue-cli/node_modules/consolidate/lib/consolidate.js:143:5
    at Promise._execute (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/node_modules/bluebird/js/release/debuggability.js:299:9)
    at Promise._resolveFromExecutor (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/node_modules/bluebird/js/release/promise.js:481:18)
    at new Promise (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/node_modules/bluebird/js/release/promise.js:77:14)
    at promisify (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/lib/consolidate.js:136:10)
    at exports.handlebars.render (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/lib/consolidate.js:724:10)
    at /usr/local/lib/node_modules/vue-cli/lib/generate.js:102:5
    at /usr/local/lib/node_modules/vue-cli/node_modules/async/dist/async.js:3047:20
    at eachOfArrayLike (/usr/local/lib/node_modules/vue-cli/node_modules/async/dist/async.js:1002:13)
    at eachOf (/usr/local/lib/node_modules/vue-cli/node_modules/async/dist/async.js:1052:9)

(I hacked a throw statement in there so I could generate a more informative error message, which itself suggests a different issue about the informative quality of the errors thrown.)

material.js, the JS file packaged with MDL, has lines like this:

 * @typedef {{ 

This causes a false positive insofar as vue-cli's efforts to sniff out files that contain Handlebars tags.

I'll be happy to put a PR together to ameliorate this issue in a few days. I'd like some feedback about how to handle this.

  • Add a property to the meta file to exclude things? "exclude": ["dist/**/*.css", "dist/**/*.js", "custom-dir/**/*", "src/my-project-meta.json"], that sort of thing
  • Be more explicit about files to process w/Handlebars, since (at least in the browserify template) there's only the one file that has Handlebars tags? Same technique, adding a property to meta: "include": ["package.json"/*, etc */]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions