forked from devcontainers/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch-packagejson.js
More file actions
21 lines (16 loc) · 852 Bytes
/
Copy pathpatch-packagejson.js
File metadata and controls
21 lines (16 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
const jsonc = require('jsonc-parser');
const fs = require('fs');
const path = require('path');
const packageJsonPath = path.join(__dirname, '..', 'package.json');
const packageJsonText = fs.readFileSync(packageJsonPath, 'utf8');
let patchedText = packageJsonText;
for (const key of ['dependencies', 'devDependencies']) {
const edits = jsonc.modify(patchedText, [key], {}, {});
patchedText = jsonc.applyEdits(patchedText, edits);
}
fs.writeFileSync(packageJsonPath, patchedText);