forked from oferh/ng2-completer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-package-json.js
More file actions
26 lines (20 loc) · 891 Bytes
/
create-package-json.js
File metadata and controls
26 lines (20 loc) · 891 Bytes
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
/**
* Creates a package.json for the release NPM package structure.
*/
const fs = require('fs');
const path = require('path');
const basePkgJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const releasePkgJson = JSON.parse(fs.readFileSync('./package.release.json', 'utf8'));
// remove scripts
delete basePkgJson.scripts;
// remove devDependencies (as there are important for the sourcecode only)
delete basePkgJson.devDependencies;
// transform dependencies to peerDependencies for the release
basePkgJson.peerDependencies = Object.assign({}, basePkgJson.dependencies);
basePkgJson.dependencies = {};
// override and add keys for release
Object.keys(releasePkgJson).forEach(key => {
basePkgJson[key] = releasePkgJson[key];
});
const filepath = path.join(__dirname, './bundles/package.json');
fs.writeFileSync(filepath, JSON.stringify(basePkgJson, null, 2), 'utf-8');