Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example not working #1

Open
mikewheaton opened this issue Jul 16, 2018 · 3 comments
Open

Example not working #1

mikewheaton opened this issue Jul 16, 2018 · 3 comments

Comments

@mikewheaton
Copy link

I'm having some trouble getting the example from the README to work. Here is what I have in gulpfile.js:

var gulp = require('gulp');
var choose = require('gulp-choose-files');

gulp.task('default', function() {
  return gulp.src('src/emails/**/*.html')
    .pipe(choose())
    .pipe(gulp.dest('dist/emails'));
});

When I run gulp I get the prompt to choose a file. But regardless of the file I choose there's an error:

(node:97106) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'relative' of undefined
    at DestroyableTransform.saveFile [as _transform] (/Users/mike/Microsoft/commenting-template/node_modules/vinyl-fs/lib/dest/index.js:36:49)
    at DestroyableTransform.Transform._read (/Users/mike/Microsoft/commenting-template/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_transform.js:184
:10)
    at DestroyableTransform.Transform._write (/Users/mike/Microsoft/commenting-template/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_transform.js:17
2:12)
    at doWrite (/Users/mike/Microsoft/commenting-template/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/Users/mike/Microsoft/commenting-template/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at DestroyableTransform.Writable.write (/Users/mike/Microsoft/commenting-template/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_writable.js:194:1
1)
    at DestroyableTransform.ondata (/Users/mike/Microsoft/commenting-template/node_modules/readable-stream/lib/_stream_readable.js:619:20)    at emitOne (events.js:116:13)
    at DestroyableTransform.emit (events.js:211:7)
    at addChunk (/Users/mike/Microsoft/commenting-template/node_modules/readable-stream/lib/_stream_readable.js:291:12)
(node:97106) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block
, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:97106) [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.

Any idea what's going on here?

@jonschlinkert
Copy link
Member

Hmm, what version of gulp are you using? Also, any info on other libs you're using, like vinyl or vinyl-fs would help.

My hunch is that the files are using an old version of vinyl. But I'm not sure yet.

@mikewheaton
Copy link
Author

I've started a new project to be sure this issue is isolated.

Here's the file structure:
image

Contents of package.json:

{
  "name": "choose-files-test",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "gulp": "^3.9.1",
    "gulp-choose-files": "^1.0.0"
  }
}

And contents of gulpfile.js:

var gulp = require('gulp');
var choose = require('gulp-choose-files');

gulp.task('default', function() {
  return gulp.src('source/**/*.txt')
    .pipe(choose())
    .pipe(gulp.dest('destination/'));
});

I've verified that I'm on the latest versions of Gulp (3.91), NPM (5.6.0), and Node (8.11.3). After running gulp and selecting one of the text files, I still have the UnhandledPromiseRejectionWarning error.

@mikewheaton
Copy link
Author

mikewheaton commented Jul 17, 2018

I modified the script to log the selected files to the console:

var log = function(file) {
  console.log('File selected:', file);
};

gulp.task('default', function() {
  return gulp.src('source/**/*.txt')
    .pipe(choose())
    .pipe(map(log));
});

If I select two of the files, gulp-choose-files is returning them but as undefined:

? Which files do you want to write?
File selected: undefined
File selected: undefined

So that explains the Cannot read property error from earlier, as it was running on an undefined object. Any tips on how I can go about debugging this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants