提交 91c7c608 编写于 作者: M Martin Aeschlimann

webpack: make sure to only modify package.json next to webpack.config

上级 1047f489
......@@ -50,9 +50,14 @@ function fromLocal(extensionPath, sourceMappingURLBase) {
var pattern = path.join(extensionPath, '/**/extension.webpack.config.js');
var webpackConfigLocations = glob.sync(pattern, { ignore: ['**/node_modules'] });
if (webpackConfigLocations.length) {
//console.log('-----' + webpackConfigLocations.join(','));
//console.log('-----' + fileNames.join(','));
var packageJsonFilter = filter('**/package.json', { restore: true });
var packageJsonFilter = filter(function (f) {
if (path.basename(f.path) === 'package.json') {
// only modify package.json's next to the webpack file.
// to be safe, use existsSync instead of path comparison.
return fs.existsSync(path.join(path.dirname(f.path), 'extension.webpack.config.js'));
}
return false;
}, { restore: true });
var patchFilesStream = filesStream
.pipe(packageJsonFilter)
.pipe(buffer())
......
......@@ -47,10 +47,15 @@ export function fromLocal(extensionPath: string, sourceMappingURLBase?: string):
const pattern = path.join(extensionPath, '/**/extension.webpack.config.js');
const webpackConfigLocations = (<string[]>glob.sync(pattern, { ignore: ['**/node_modules'] }));
if (webpackConfigLocations.length) {
//console.log('-----' + webpackConfigLocations.join(','));
//console.log('-----' + fileNames.join(','));
const packageJsonFilter = filter('**/package.json', { restore: true });
const packageJsonFilter = filter(f => {
if (path.basename(f.path) === 'package.json') {
// only modify package.json's next to the webpack file.
// to be safe, use existsSync instead of path comparison.
return fs.existsSync(path.join(path.dirname(f.path), 'extension.webpack.config.js'));
}
return false;
}, { restore: true });
const patchFilesStream = filesStream
.pipe(packageJsonFilter)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册