Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-choose-files

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-choose-files - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

82

index.js
'use strict';
var through = require('through2');
var extend = require('extend-shallow');
var Prompt = require('prompt-checkbox');
const through = require('through2');
const { prompt } = require('enquirer');
module.exports = function(options) {
var opts = extend({key: 'relative', save: false}, options);
var msg = opts.message || 'Which files do you want to write?';
var paths = [];
var files = {};
const fileKey = (file, options) => {
if (typeof options.key === 'string') return file[options.key];
if (typeof options.key === 'function') return options.key(file);
return file.relative;
};
return through.obj(function(file, enc, next) {
module.exports = options => {
const opts = Object.assign({ key: 'relative' }, options);
const message = opts.message || 'Which files do you want to write?';
const predefined = [].concat(opts.paths || []);
const choices = [];
const files = {};
return through.obj((file, enc, next) => {
if (opts.skip) {

@@ -19,23 +25,16 @@ next(null, file);

var key = fileKey(file, opts);
paths.push(key);
files[key] = file;
next();
}, function(next) {
var stream = this;
if (typeof opts.choices === 'string') {
opts.choices = [opts.choices];
let key = fileKey(file, opts);
if (predefined.length && predefined.includes(key)) {
next(null, file);
return;
}
if (Array.isArray(opts.choices)) {
opts.choices.forEach(function(filepath) {
stream.push(files[filepath]);
});
next();
return;
if (!predefined.length) {
choices.push(key);
files[key] = file;
}
if (paths.length === 0) {
next();
}, function(next) {
if (!choices.length) {
next();

@@ -45,32 +44,11 @@ return;

var answers = {};
var prompt = new Prompt({
name: 'files',
message: msg,
type: 'checkbox',
choiceObject: true,
radio: true,
choices: paths
});
prompt.run(answers)
.then(function(answers) {
answers.forEach(function(filepath) {
stream.push(files[filepath]);
});
prompt({ type: 'multiselect', name: 'paths', message, choices, ...options })
.then(answers => {
if (answers.paths && answers.paths.length) {
answers.paths.forEach(filename => this.push(files[filename]));
}
next();
})
.catch(next);
});
};
function fileKey(file, opts) {
if (typeof opts.key === 'string') {
return file[opts.key];
}
if (typeof opts.key === 'function') {
return opts.key(file);
}
return file.relative;
}
{
"name": "gulp-choose-files",
"description": "Gulp plugin that prompts you to choose the files to pass through the stream.",
"version": "1.0.0",
"version": "2.0.0",
"homepage": "https://github.com/generate/gulp-choose-files",

@@ -17,3 +17,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"engines": {
"node": ">=0.10.0"
"node": ">=8"
},

@@ -24,11 +24,8 @@ "scripts": {

"dependencies": {
"extend-shallow": "^2.0.1",
"prompt-checkbox": "^0.5.0",
"through2": "^2.0.3"
"enquirer": "^2.3.0",
"through2": "^3.0.1"
},
"devDependencies": {
"assemble": "^0.23.0",
"engine-handlebars": "^0.8.2",
"gulp": "^3.9.1",
"gulp-format-md": "^0.1.12"
"gulp": "^4.0.0",
"gulp-format-md": "^2.0.0"
},

@@ -67,6 +64,2 @@ "keywords": [

},
"reflinks": [
"verb",
"verb-readme-generator"
],
"lint": {

@@ -73,0 +66,0 @@ "reflinks": true

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc