forked from microsoft/accessibility-insights-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-docker-image-package-json.js
29 lines (23 loc) · 1 KB
/
create-docker-image-package-json.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
const fs = require('fs');
const packageJson = require(process.cwd() + '/package.json');
const getWebpackConfig = require(process.cwd() + '/webpack.config');
const packageDependencies = packageJson.dependencies;
const webpackConfig = getWebpackConfig();
const webpackExternals = webpackConfig.externals ? webpackConfig.externals : [];
const imagePackageDependencies = {};
webpackExternals.forEach((packageName) => {
if (packageDependencies.hasOwnProperty(packageName)) {
imagePackageDependencies[packageName] = packageDependencies[packageName];
} else {
throw new Error(`Package '${packageName}' is not declared in package.json dependencies{} section.`);
}
});
const newPackageJson = {
...packageJson,
scripts: undefined,
dependencies: imagePackageDependencies,
devDependencies: undefined,
};
fs.writeFileSync('./dist/package.json', JSON.stringify(newPackageJson, undefined, 4));