Inject fails for version 4.2.0
See original GitHub issueHello, inject seems to fail suddenly without any change in the task. This is the error I which I am facing,
(node:51098) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'startTag' of undefined
(node:51098) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
My gulp task: `gulp.task(‘update:index’, function () { var target = gulp.src(‘./app/index.html’);
var injectOptions = function(name){
return {name: name, addRootSlash: false, transform: function(path){
return '<script src="'+ path.replace('app/', '')+'"></script>'
}}};
//Order must not change to avoid injector errors as angular looks the files in this order while bootstrapping the app
return target.pipe(inject(gulp.src(['./app/**/*.module.js']), injectOptions('module.js')))
//all parent level js files
.pipe(inject(gulp.src(['./app/*.js', '!./app/app.module.js', '!./app/*.spec.js'], {read:false}), injectOptions('main app')))
.pipe(inject(gulp.src(['./app/api/api.services.js'], {read:false}), injectOptions('api service')))
//all js files under api folder except module/services
.pipe(inject(gulp.src(['./app/api/*.js', '!./app/api/*.module.js', '!./app/api/*.services.js', '!./app/api/*.spec.js'], {read:false}),
injectOptions('api')))
.pipe(inject(gulp.src(['./app/utils/stringUtils.js'], {read:false}), injectOptions('stringutils')))
//all files under utils except module/stringUtils
.pipe(inject(gulp.src(['./app/utils/*.js', '!./app/utils/*.module.js', '!./app/utils/stringUtils.js', '!./app/utils/*.spec.js'], {read:false}),
injectOptions('utils')))
//all files under authentication except module
.pipe(inject(gulp.src(['./app/authentication/*.js', '!./app/authentication/*.module.js', '!./app/authentication/*.spec.js'], {read:false}),
injectOptions('authentication')))
//all files under shared except module
.pipe(inject(gulp.src(['./app/shared/*.js', '!./app/shared/*.module.js', '!./app/shared/*.spec.js'], {read:false}), injectOptions('shared')))
//all directives which are named as directive/directives which are under components
.pipe(inject(gulp.src(['./app/components/**/*.directive.js', './app/components/**/*.directives.js'], {read:false}),
injectOptions('component directives')))
//all services under components
.pipe(inject(gulp.src(['./app/components/**/*.service.js'], {read:false}),
injectOptions('component services')))
//all other js files under components which are neither directive/directives nor services
.pipe(inject(gulp.src(['./app/components/**/*.js',
'!./app/components/**/*.service.js', '!./app/components/**/*.directive.js',
'!./app/components/**/*.directives.js', '!./app/components/**/*.module.js', '!./app/components/**/*.spec.js'], {read:false}),
injectOptions('other component files')))
.pipe(gulp.dest('./app'));
});`
There seems to be some dependency updates which I have observed,
new [INFO] ├─┬ gulp-inject@4.2.0 [INFO] │ ├── arrify@1.0.1 [INFO] │ ├── escape-string-regexp@1.0.5 [INFO] │ ├─┬ group-array@0.3.2 [INFO] │ │ ├── arr-flatten@1.0.1 [INFO] │ │ ├── get-value@2.0.6 [INFO] │ │ ├─┬ kind-of@3.1.0 [INFO] │ │ │ └── is-buffer@1.1.4 [INFO] │ │ └─┬ union-value@0.2.3 [INFO] │ │ ├── arr-union@3.1.0 [INFO] │ │ └─┬ set-value@0.3.3 [INFO] │ │ ├── extend-shallow@2.0.1 [INFO] │ │ └─┬ to-object-path@0.2.0 [INFO] │ │ └── is-arguments@1.0.2 [INFO] │ └─┬ stream-to-array@2.3.0 [INFO] │ └── any-promise@1.3.0
OLD which was working
[INFO] ├─┬ gulp-inject@4.2.0 [INFO] │ ├── arrify@1.0.1 [INFO] │ ├── escape-string-regexp@1.0.5 [INFO] │ ├─┬ group-array@0.3.1 [INFO] │ │ ├── get-value@2.0.6 [INFO] │ │ └─┬ kind-of@3.1.0 [INFO] │ │ └── is-buffer@1.1.4 [INFO] │ └─┬ stream-to-array@2.3.0 [INFO] │ └── any-promise@1.3.0
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:12 (2 by maintainers)
Top GitHub Comments
It worked after changing package.json from group-array : “^0.3.0” to group-array: “0.3.1”.
Please try to fix the dependencies.
gulp inject [00:12:32] Using gulpfile ~\Documents\NodejsWorkshop\gulpfile.js [00:12:32] Starting ‘inject’… (node:26112) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object] (node:26112) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
var gulp = require(‘gulp’); var jshint = require(‘gulp-jshint’); var jscs = require(‘gulp-jscs’); var nodemon = require(‘gulp-nodemon’); var jsFiles = [‘.js’,'src/**/.js’]; gulp.task(‘style’,function(){ return gulp.src(jsFiles) .pipe(jshint()) .pipe(jshint.reporter(‘jshint-stylish’, {verbose : true})) .pipe(jscs());
});
gulp.task(‘inject’,function(){ var wiredep = require(‘wiredep’).stream; var inject = require(‘gulp-inject’);
var injectSrc = gulp.src([‘,/public/css/.css’, './public/js/.js’],{read : false}); var injectOptions = { ignorePath: ‘/public’ }; var options = { bowerJson : require(‘./bower.json’), directory : ‘./public/lib’ }; return gulp.src(‘./src/views/*.html’) .pipe(wiredep(options)) .pipe(inject(injectSrc, injectOptions)) .pipe(gulp.dest(‘./src/views’));
});
please help!