unlight / fusebox-gulp-plugin

Adapt gulp plugins to work with fuse-box
3 stars 0 forks source link

TypeError: stream.on is not a function #7

Closed rs3d closed 7 years ago

rs3d commented 7 years ago

Hi,

I try to use https://github.com/thomas-darling/gulp-translate like this:

const fuse = FuseBox.init({
  homeDir: "app",
  output: "bin-assets/scripts/$name.js",
  plugins: [
    GulpPlugin([
      (file) => {
        if (file.relativePath.substr(-4) !== 'html') {
          return;
        }
        return g.translate(translatePluginConfig).import({
          missingContentHandling: 'warn',
          importFilePath: `languages/import/kapilendo.de-DE.translation.json`
        });
      }
    ]),
    HTMLPlugin()
  ]
});

... and get following error message after the last html file:

TypeError: Cannot read property 'on' of null
    at destroyer (D:\project\node_modules\pump\index.js:24:9)
    at D:\project\node_modules\pump\index.js:68:12
    at Array.map (native)
    at pump (D:\project\node_modules\pump\index.js:65:26)
    at Pumpify.setPipeline (D:\project\node_modules\pumpify\index.js:39:5)
    at new Pumpify (D:\project\node_modules\pumpify\index.js:15:30)
    at Function.Pumpify [as obj] (D:\project\node_modules\pumpify\index.js:13:44)
    at FuseBoxGulpPlugin.transform (D:\project\node_modules\fusebox-gulp-plugin\lib\index.js:25:32)
    at tasks.push (D:\project\node_modules\fuse-box\dist\commonjs\core\File.js:128:59)
    at context.queue.realm_utils_1.each.promise (D:\project\node_modules\fuse-box\dist\commonjs\core\File.js:132:76)
unlight commented 7 years ago

Hi, please, provide your version of fuse-box.

rs3d commented 7 years ago

fuse-box 2.1.0 fusebox-gulp-plugin 1.0.4 node 6.11.0 (win)

unlight commented 7 years ago

Suspicious code:

        if (file.relativePath.substr(-4) !== 'html') {
          return;
        }

You return undefined here, but you must return vinyl stream. If you want to filter files, you need do it by another way.

rs3d commented 7 years ago

Yes, you're right!

I've visited the docs again and saw that I can already filter by extension (sorry!)

Working code

const fuse = FuseBox.init({
  homeDir: "app",
  output: "bin-assets/scripts/$name.js",
  log: true,
  debug: true,
  tsConfig: "tsconfig.json",
  plugins: [
    [".html",
      GulpPlugin([
        (file) => {
          return g.translate(translatePluginConfig).import({
            missingContentHandling: 'warn',
            importFilePath: `translation.json`
          });
        }
      ])],
    HTMLPlugin()
  ]
});