in src/main.ts [122:161]
export function bundleMetaDataFiles(id: string, outDir: string): ThroughStream {
let base: string | undefined = undefined;
const bundler = new MetaDataBundler(id, outDir);
return through(function (this: ThroughStream, file: File) {
const basename = path.basename(file.relative);
if (basename.length < NLS_METADATA_JSON.length || NLS_METADATA_JSON !== basename.substr(basename.length - NLS_METADATA_JSON.length)) {
this.queue(file);
return;
}
if (file.isBuffer()) {
if (!base) {
base = file.base;
}
} else {
this.emit('error', `Failed to bundle file: ${file.relative}`);
return;
}
if (!base) {
base = file.base;
}
const buffer: Buffer = file.contents as Buffer;
const json: SingleMetaDataFile = JSON.parse(buffer.toString('utf8'));
bundler.add(json);
}, function () {
if (base) {
const [header, content] = bundler.bundle();
this.queue(new File({
base: base,
path: path.join(base, 'nls.metadata.header.json'),
contents: new Buffer(JSON.stringify(header), 'utf8')
}));
this.queue(new File({
base: base,
path: path.join(base, 'nls.metadata.json'),
contents: new Buffer(JSON.stringify(content), 'utf8')
}));
}
this.queue(null);
});
}