-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Got a TypeError parsing some files
[14:25:32] starting generate
[14:25:33] ✔ running tasks: [ 'swap-rest-api:dev' ]
[14:25:33] starting swap-rest-api
[14:25:33] starting swap-rest-api:dev task
[14:25:33] starting swap-rest-api:auto-prompt task
{ destination: '/home/remi/app/test-manual/test-manual' }
[14:25:33] finished swap-rest-api:auto-prompt task 1ms
[14:25:33] starting swap-rest-api:api task
[14:25:33] starting swap-rest-api.api
[14:25:33] starting swap-rest-api.api:default task
[14:25:33] starting swap-rest-api.api:api task
{ TypeError: file.has is not a function
at stripPrefixes (/home/remi/app/node_modules/common-middleware/index.js:104:12)
at /home/remi/app/node_modules/middleware-utils/index.js:42:9
at next (/home/remi/app/node_modules/async-array-reduce/index.js:29:5)
at /home/remi/app/node_modules/async-array-reduce/index.js:34:7
at /home/remi/app/node_modules/middleware-utils/index.js:44:11
at escape (/home/remi/app/node_modules/common-middleware/index.js:138:5)
at /home/remi/app/node_modules/middleware-utils/index.js:42:9
at next (/home/remi/app/node_modules/async-array-reduce/index.js:29:5)
at /home/remi/app/node_modules/async-array-reduce/index.js:34:7
at /home/remi/app/node_modules/middleware-utils/index.js:44:11
_handled: true,
source: 'at stripPrefixes (/home/remi/app/node_modules/common-middleware/index.js:104:12)',
reason: 'generator#handle("onLoad"): /home/remi/app/dist/assets/templates/generate-api/src/assets/img/brand.png',
file: <File "src/assets/img/brand.png" <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 e9 00 00 00 51 08 06 00 00 01 40 a9 b1 6d 00 00 00 09 70 48 59 73 00 00 0b 13 00 00 0b 13 01 ... >> }The error is thrown here: https://github.com/jonschlinkert/common-middleware/blob/master/index.js#L115
Here is a quick fix that solve the issue but we have to know why it happens. I don't know that for now.
/**
* strip prefixes from dotfile and config templates
*/
function stripPrefixes(file, next) {
if (!/templates/.test(file.dirname)) {
next(null, file);
return;
}
if (!file.prototype) {
console.log(require('chalk').red('File is not a Vinyl object'), file)
next(null, file)
return
}
if (file.has && file.has('action.stripPrefixes')) {
next(null, file);
return;
}
file.set('action.stripPrefixes', true);
file.basename = file.basename.replace(/^_/, '.');
file.basename = file.basename.replace(/^\$/, '');
next(null, file);
}Metadata
Metadata
Assignees
Labels
No labels