Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'spritesmithOptions': {},
// Used to format output CSS
// You should be using a separate beautifier plugin
'outputIndent': '\t'
};
var settings = extend({}, defaults, options);
// Keep track of all the chunks that come in so that we can re-emit in the flush
var chunkList = [];
// We use an object for imageMap so we don't get any duplicates
var imageMap = {};
// Check to make sure all of the images exist(`options.shouldVerifyImagesExist`) before trying to sprite them
var imagePromiseArray = [];
var stream = through.obj(function(chunk, enc, cb) {
// http://nodejs.org/docs/latest/api/stream.html#stream_transform_transform_chunk_encoding_callback
//console.log('transform');
// Each `chunk` is a vinyl file: https://www.npmjs.com/package/vinyl
// chunk.cwd
// chunk.base
// chunk.path
// chunk.contents
if (chunk.isStream()) {
self.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Cannot operate on stream'));
}
else if (chunk.isBuffer()) {
var contents = String(chunk.contents);
var defaultRewrite = function (url) {
if (isLocalPath(url))
return joinBaseAndPath(options.base, url);
return url;
};
if (typeof options.rewriter !== 'function') {
rewriteURL = defaultRewrite;
}
else {
rewriteURL = function (url) {
return options.rewriter(url, defaultRewrite);
}
}
// Creating a stream through which each file will pass
return through.obj(function(file, enc, cb) {
var srcFile = file.path
if (file.isNull()) {
// return empty file
cb(null, file);
}
if (file.isBuffer()) {
if (/\.css$/.test(srcFile)) {
// It's a CSS file.
var oldCSS = String(file.contents),
newCSS = rewriteCSSURLs(oldCSS, rewriteURL)
file.contents = new Buffer(newCSS);
gutil.log("Changed CSS file: \"" + srcFile + "\"");
}
else {
// It's an HTML file.
function babelify(js, dir = '') {
const babelConfig = getBabelCommonConfig();
const stream = js.pipe(babel(babelConfig));
return stream
// eslint-disable-next-line func-names
.pipe(through2.obj(function (file, encoding, next) {
const matches = file.path.match(/(routes|dashboard|guide|entry|entrywithoutsider)\.nunjucks\.(js|jsx)/);
if (matches) {
const content = file.contents.toString(encoding);
file.contents = Buffer.from(content
.replace(`'{{ ${matches[1]} }}'`, `{{ ${matches[1]} }}`)
// eslint-disable-next-line quotes
.replace(`'{{ home }}'`, '{{ home }}')
// eslint-disable-next-line quotes
.replace(`'{{ master }}'`, '{{ master }}'));
}
this.push(file);
next();
}))
.pipe(gulp.dest(path.join(libDir, dir)));
}
function resolutionStream (headA, headB) {
if (args.stdin) return pumpify.obj(process.stdin, ndjson.parse())
var pipeline = []
pipeline.push(db.diff(headA, headB))
if (args.left || args.right || args.random) {
var choice = 0 // left
if (args.right) choice = 1
if (args.random) choice = +(Math.random() < 0.5)
pipeline.push(through.obj(function (versions, enc, next) {
var winner = versions[choice]
debug('versions', versions)
debug('winner', winner)
next(null, winner)
}))
} else { // manual
pipeline.push(batcher(args.limit))
pipeline.push(manualMergeStream({vizFn: vizFn}))
}
return pumpify.obj(pipeline)
}
})
function renameIDLabels(map) {
var buf = []; // buffer so each row is renamed before continuing
return through.obj(function(row, enc, next) {
if (map[row.id]) {
row.id = map[row.id];
}
if (row.dedupe && map[row.dedupe]) {
row.dedupe = map[row.dedupe];
}
forOwn(row.deps, function(dep, key) {
if (map[dep]) {
row.deps[key] = map[dep];
}
});
buf.push(row);
next();
}, function() {
buf.forEach(function(row) {
this.push(row);
const path = require("path");
const through2 = require("through2");
const level = require("level");
level(path.join(__dirname, "../data"))
.createReadStream()
.pipe(
through2.obj((item, enc, next) => {
console.log(item.key);
console.log(" " + item.value);
next();
})
);
return new Promise((resolve, reject) => {
try {
logger(
'Firestore.readStream', requestTag,
'Sending request: %j', decorated.request);
let stream = gapicClient[methodName](
decorated.request, decorated.gax);
let logStream = through2.obj(function(chunk, enc, callback) {
logger(
'Firestore.readStream', requestTag,
'Received response: %j', chunk);
this.push(chunk);
callback();
});
resolve(bun([stream, logStream]));
} catch (err) {
logger(
'Firestore.readStream', requestTag,
'Received error:', err);
reject(err);
}
})
.then(stream => this._initializeStream(stream, requestTag));
const trimSemicolon = () => {
function filter(file, enc, cb) {
file.contents = file.contents.slice(0, -1);
cb(null, file);
}
return through.obj(filter);
};
`(${colors.red(failure.current)} does not satisfy ` +
`${colors.yellow(failure.requested)})`
);
});
var msg =
'Some of your dependencies are outdated. Please run ' +
`${colors.bold('npm update')} to ensure you are up to date.`;
cb(new PluginError(PLUGIN_NAME, msg));
return;
}
cb();
});
}
return through.obj(read);
};