Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const outputFile1 = file.clone({ contents: false }),
outputFile2 = file.clone({ contents: false });
outputFile1.contents = new Buffer(`${String(file.contents)}-1`);
outputFile2.contents = new Buffer(`${String(file.contents)}-2`);
this.push(outputFile1);
this.push(outputFile2);
cb(null);
});
const pushedFilesCount = 2;
const targetFile = new File({
contents: new Buffer('abufferwiththiscontent')
});
fakeTask = through.obj(updatedFileHandler);
const opts = {
value: sandbox.spy(cache.defaultOptions.value),
restore: sandbox.spy(cache.defaultOptions.restore)
};
// Create a proxied plugin stream
let proxied = cache(fakeTask, opts),
count = 0;
cacheStep();
cachedValuesWithNormalPaths.forEach((cachedFile) => {
// Extend the cached value onto the file, but don't overwrite original path info
const file = new File({
// custom properties
...cachedFile,
// file info
...pick(inputFile, ['cwd', 'base', 'stat', 'history', 'path']),
// file contents
contents: cachedFile.contents
});
// Restore the file path if it was set
if (cachedFile.path && cachedFile.gulpCache$filePathChangedInsideTask) {
file.path = cachedFile.path;
}
// Restore the file base if it was set
if (cachedFile.base && cachedFile.gulpCache$fileBaseChangedInsideTask) {
file.base = cachedFile.base;
test.cb('should not render a stream', t => {
const stream = gulpHb();
stream.on('error', error => {
t.is(error.message, 'Streaming not supported.');
t.end();
});
stream.write(new File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: new Readable()
}));
});
function write(cb) {
allMessages = getUniqueBlocks(allMessages)
const potFile = new Vinyl({
base: process.cwd(),
path: options.output,
contents: Buffer.from(toPot(allMessages)),
})
this.push(potFile)
console.log(`Writing .pot file to ${options.output}`.green)
cb()
}
const localeString = JSON.stringify(localeFile)
const defaultLocale = options && options.defaultLocale || DEFAULT_LOCALE
const fallbackLocale = options && options.fallbackLocale || DEFAULT_FALLBACK_LOCALE
const wxsContent = `var fallbackLocale='${fallbackLocale}';var translations=${localeString};\n${getWxsCode()}`
const jsContent = `module.exports.fallbackLocale='${fallbackLocale}';module.exports.defaultLocale='${defaultLocale}';module.exports.translations=${localeString};`
const wxsFile = new File({
cwd: firstFile.cwd,
base: firstFile.base,
path: path.join(firstFile.base, wxsFileName),
contents: Buffer.from(wxsContent),
})
const jsFile = new File({
cwd: firstFile.cwd,
base: firstFile.base,
path: path.join(firstFile.base, jsFileName),
contents: Buffer.from(jsContent),
})
this.push(wxsFile)
this.push(jsFile)
cb()
}
sourceMaps: this.sourceMaps,
manifestVersion: 6,
...(setSDKVersion && {
sdkVersion: {
...(this.components.watch && this.hasJS && { deviceApi }),
...(this.components.companion && { companionApi }),
},
}),
requestedPermissions: this.projectConfig.requestedPermissions,
appId: this.projectConfig.appUUID,
},
undefined,
2,
);
this.push(
new Vinyl({
contents: Buffer.from(manifestJSON, 'utf8'),
path: path.resolve(process.cwd(), manifestPath),
}),
);
callback();
}
}
function emitAsset({ fileName, source }: rollup.OutputAsset) {
stream.push(
new Vinyl({
contents: Buffer.isBuffer(source)
? source
: Buffer.from(source, 'utf8'),
path: resolve(process.cwd(), generatePath(fileName)),
}),
);
}
new Promise((resolve, reject) => {
const metadata = renderLayouts(new File({
path: './.tmp',
layout: 'opfMetadata',
contents: new Buffer(resp.bookmeta.join(''))
}), tmpl.opf).contents.toString()
const manifest = renderLayouts(new File({
path: './.tmp',
layout: 'opfManifest',
contents: new Buffer(cjoin(resp.manifest))
}), tmpl.opf).contents.toString()
resolve({ metadata, manifest })
})
static stylesheet(inline = false) {
return inline
? new File({ contents: Buffer.from('<style>{% body %}</style>') })
: new File({
contents: Buffer.from(
''
),
})
}
xml:lang="en"
unique-identifier="uuid"
xmlns="http://www.idpf.org/2007/opf"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
prefix="ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/">
{% body %}
`),
})
const opfMetadata = new File({
path: 'opfMetadata.tmpl',
contents: new Buffer(''),
})
const opfManifest = new File({
path: 'opfManifest.tmpl',
contents: new Buffer('{% body %}'),
})
const opfSpine = new File({
path: 'opfSpine.tmpl',
contents: new Buffer('{% body %}'),
})
const opfGuide = new File({
path: 'opfGuide.tmpl',
contents: new Buffer('{% body %}'),
})
const manifestItem = (file) => {
const props = Props.testHTML(file)