more tweaks

This commit is contained in:
Johannes Rieken
2018-08-13 18:52:12 +02:00
parent 0425b36c5d
commit bb07163524
2 changed files with 14 additions and 10 deletions

View File

@@ -63,16 +63,18 @@ export function fromLocal(extensionPath: string, sourceMappingURLBase?: string):
// source map handling:
// * rewrite sourceMappingURL
// * save to disk so that upload-task picks this up
if (sourceMappingURLBase && /\.js\.map$/.test(data.path)) {
if (sourceMappingURLBase) {
const contents = (<Buffer>data.contents).toString('utf8');
data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) {
return `${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/out/${g1}`;
return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/out/${g1}`;
}), 'utf8');
if (!fs.existsSync(path.dirname(data.path))) {
fs.mkdirSync(path.dirname(data.path));
if (/\.js\.map$/.test(data.path)) {
if (!fs.existsSync(path.dirname(data.path))) {
fs.mkdirSync(path.dirname(data.path));
}
fs.writeFileSync(data.path, data.contents);
}
fs.writeFileSync(data.path, data.contents);
}
this.emit('data', data);