Giter Club home page Giter Club logo

gulp-di's People

Contributors

cmtt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

skitto0307

gulp-di's Issues

Expose gulp-util in DI contexts

As gulp-util is always a dependency of Gulp, it might be included in gulp-di's scope.
This would allow its users to access CLI parameters among other useful methods

Does not parse ES2015 functions properly

Please see this issue:

Gulp can be used in conjunction with ES2015 code in two ways:

  1. Writing ES2015+ code - the "gulpfile.js" would be written in ES2015+, as Node.js supports already a subset of the new standard.
  2. Writing ES2015+ code using the "Babel" transpiler - the "gulpfile.babel.js" and all imported modules would be transpiled back to ES5 code. In this case, parse-function would work as intended.

It would be also possible to make use of a JavaScript parser like esprima or acorn.

Doc example show di instance with params in wrong order

Ie the api example is:

GulpDI(object gulp, object options)

The code example is:

let di = GulpDI({
  DEBUG: false, // when set to true, the plugin will log info to console. Useful for bug reporting and issue debugging
  pattern: ['gulp-*', 'gulp.*'], // the glob(s) to search for
  config: 'package.json', // where to find the plugins, by default searched up from process.cwd()
  scope: ['dependencies', 'devDependencies', 'peerDependencies'], // which keys in the config to look within
  replaceString: /^gulp(-|\.)/, // what to remove from the name of the module when adding it to the context
  rename: {}, // a mapping of plugins to rename
  renameFn: function (name) { ... } // a function to handle the renaming of plugins (the default works)
}, require('gulp'));

Subsequently the error for putting them in the wrong order doesn't make it very obvious. :)

$ gulp
/home/adam/Programming/work/salespreso-gulp-v2/node_modules/gulp-di/contrib/help.js:104
    return _task.apply(gulp, args);
                ^

TypeError: Cannot read property 'apply' of undefined
    at Object.HelpTask.gulp.task (/home/adam/Programming/work/salespreso-gulp-v2/node_modules/gulp-di/contrib/help.js:104:17)
    at GulpDI.HelpTask (/home/adam/Programming/work/salespreso-gulp-v2/node_modules/gulp-di/contrib/help.js:109:8)
    at GulpDI.$injector (/home/adam/Programming/work/salespreso-gulp-v2/node_modules/gulp-di/lib/di.js:56:20)
    at GulpDI.inject (/home/adam/Programming/work/salespreso-gulp-v2/node_modules/gulp-di/lib/di.js:192:30)
    at GulpDI.parseOptions (/home/adam/Programming/work/salespreso-gulp-v2/node_modules/gulp-di/lib/di.js:161:14)
    at new GulpDI (/home/adam/Programming/work/salespreso-gulp-v2/node_modules/gulp-di/lib/di.js:118:12)
    at /home/adam/Programming/work/salespreso-gulp-v2/node_modules/gulp-di/lib/di.js:330:12
    at module.exports (/home/adam/Programming/work/salespreso-gulp-v2/index.js:6:14)
    at Object.<anonymous> (/home/adam/Programming/work/salespreso-gulp-v2/examples/jspm/gulpfile.js:4:1)
    at Module._compile (module.js:413:34)

Don't work whith gulp 4

node -v
v6.5.0

{
  "name": "gulpdi-test",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "gulp": "gulp"
  },
  "devDependencies": {
    "babel-preset-es2015": "^6.18.0",
    "babel-register": "^6.18.0",
    "del": "^2.2.2",
    "gulp": "github:gulpjs/gulp#4.0",
    "gulp-debug": "^2.1.2",
    "gulp-di": "0.0.33",
    "gulp-sass": "^2.3.2",
    "make-targs": "github:pvlv/make-targs#v1.0.0",
    "run-sequence": "^1.2.2"
  }
}
// /tasks/styles.js

'use strict';

module.exports = (gulp, sass) => {
  gulp.task('styles', () => {
    return gulp.src('./fixtures/styles/*.scss')
      .pipe(sass())
      .pipe(gulp.dest('./results/css/'));
  })
}
// /tasks/default.js

'use strict';

module.exports = function (gulp) {
  gulp.task('default', gulp.parallel(
      'styles'
  ));
}
// /gulpfile.js

const gulp = require('gulp');

const di = require('gulp-di')(gulp, {
  pattern: ['gulp-*', 'gulp.*']
});

di
  .tasks('./tasks')
  .resolve();

module.exports = gulp;

Stack trace

assert.js:85
  throw new assert.AssertionError({
  ^
AssertionError: Task never defined: styles
    at getFunction (/data/node_modules/undertaker/lib/helpers/normalizeArgs.js:15:5)
    at arrayMap (/data/node_modules/lodash.map/index.js:140:21)
    at map (/data/node_modules/lodash.map/index.js:1836:10)
    at normalizeArgs (/data/node_modules/undertaker/lib/helpers/normalizeArgs.js:19:10)
    at Gulp.parallel (/data/node_modules/undertaker/lib/parallel.js:13:14)
    at GulpDI.module.exports (/data/tasks/default.js:4:29)
    at GulpDI.resolve (/data/node_modules/gulp-di/lib/di.js:261:34)
    at Object.<anonymous> (/data/gulpfile.js:10:4)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)

If install gulp 3.8.1 - gulp-di work correctly

.byId should not return unresolved modules

When .byId() is used to access a module before .resolve() was called, the entire dependency injection notation will be returned. This should be avoided by throwing an error.

(In contrast, .byId can be called to access constants which were declared beforehand. This behavior allows to use .inject() calls, f.e. for configuration.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.