Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
run() {
// TODO: Do something more robust?
if (this.running) throw new Error('LocalSourceRunner already running');
this.running = true;
// Clear runner-output-data.
this.eachFilePromises = [];
this.fileResults = [];
this.sourceHash = this.getGitHash();
// Compose fresh set of memos for main pipeline computation(s).
this.pipeline = this.createPipeline();
// Find files for pipeline inputs
this.globStream = gs.create(`${this.sourcePath}/**/*.${this.extension}`, {
ignore: this.ignoreGlobs,
});
this.globStream.on(
'data',
file => this.processFile(file.path.substr(`${this.sourcePath}/`.length))
);
// Return Promise handled by streaming input event listeners.
return new Promise((resolve, reject) => {
this.globStream.on('error', error => {
return Promise.resolve(this.onError(resolve, reject, error));
});
this.globStream.on('end', data => {
return Promise.all(this.eachFilePromises).then(
this.onDataReady.bind(this, resolve, reject, data),
this.onError.bind(this, resolve, reject)
gulp.task('bundle', function() {
var tmplify = require('./tmplify');
var gs = require('glob-stream');
return gs.create('./test/browserify/*-unit-tests.js')
.on('data', function(file) {
// file has path, base, and cwd attrs
var fileName = file.path.slice(file.base.length, -14);
browserify(file.path, {debug:true})
.transform(tmplify)
.bundle()
.pipe(fs.createWriteStream('./test/browserify/bundles/' + fileName + "-bundle.js"))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
});
});
});
if (!isValidGlob(glob)) {
throw new Error('Invalid glob argument: ' + glob);
}
// return dead stream if empty array
if (Array.isArray(glob) && glob.length === 0) {
process.nextTick(pass.end.bind(pass));
return pass;
}
var options = defaults({}, opt, {
read: true,
buffer: true
});
var globStream = gs.create(glob, options);
// when people write to use just pass it through
var outputStream = globStream
.pipe(through.obj(createFile))
.pipe(getStats(options));
if (options.read !== false) {
outputStream = outputStream
.pipe(getContents(options));
}
return outputStream.pipe(pass);
}
}, opt);
var pass, inputPass;
if (!isValidGlob(glob)) {
throw new Error('Invalid glob argument: ' + glob);
}
// return dead stream if empty array
if (Array.isArray(glob) && glob.length === 0) {
pass = through.obj();
if (!options.passthrough) {
process.nextTick(pass.end.bind(pass));
}
return pass;
}
var globStream = gs.create(glob, options);
var outputStream = globStream
.pipe(resolveSymlinks())
.pipe(through.obj(createFile));
if (options.since) {
outputStream = outputStream
.pipe(filterSince(options.since));
}
if (options.read !== false) {
outputStream = outputStream
.pipe(getContents(options));
}
if (options.passthrough) {
gulp.task('bundle', function() {
var tmplify = require('jsrender/tmplify');
var gs = require('glob-stream');
return gs.create('./test/browserify/*-unit-tests.js')
.on('data', function(file) {
// file has path, base, and cwd attrs
var fileName = file.path.slice(file.base.length, -14);
browserify(file.path, {debug:true})
.transform(tmplify)
.bundle()
.pipe(fs.createWriteStream('./test/browserify/bundles/' + fileName + "-bundle.js"))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
});
});
});
gulp.task('bundle', function() {
var tmplify = require('jsrender/tmplify');
var gs = require('glob-stream');
return gs.create('./test/browserify/*-unit-tests.js')
.on('data', function(file) {
// file has path, base, and cwd attrs
var fileName = file.path.slice(file.base.length, -14);
browserify(file.path, {debug:true})
.transform(tmplify)
.bundle()
.pipe(fs.createWriteStream('./test/browserify/bundles/' + fileName + "-bundle.js"))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
});
});
});
function glob(globArray){
var stream = gs.create(globArray, { allowEmpty: true });
return new Promise(function(resolve, reject){
var files = [];
stream.on('data', function(fileObj){
files.push(new File(fileObj));
});
stream.on('end', function(err){
err && reject(err);
!err && resolve(files);
});
});
}
var files = function(dir, format) {
return gs.create(dir)
.pipe(through.obj(function(file, enc, callback) {
this.push(format(path.basename(file.path)));
callback();
}));
};
module.exports = function index(root, cb) {
root = path.join(root, '../playing');
return gs.create([
root + '/*.*',
root + '/**/*.*',
root + '/**/.*',
root + '/.*'
], {
cwd: root
}).on('data', cb);
};