-
Notifications
You must be signed in to change notification settings - Fork 57
/
del-dev-dep.cjs
30 lines (25 loc) · 955 Bytes
/
del-dev-dep.cjs
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
30
const fs = require('fs');
function removeKey(obj, key) {
const { [key]: omit, ...rest } = obj;
return rest;
}
fs.readFile('package.json', 'utf8', (err, data) => {
if (err) {
console.error('Error reading package.json:', err);
return;
}
let packageJson = JSON.parse(data);
const keyToRemove = "vue-data-ui";
if (packageJson.devDependencies && packageJson.devDependencies[keyToRemove]) {
packageJson.devDependencies = removeKey(packageJson.devDependencies, keyToRemove);
fs.writeFile('package.json', JSON.stringify(packageJson, null, 2), 'utf8', (err) => {
if (err) {
console.error('Error writing to package.json:', err);
return;
}
console.log('-- BUILD : Removed local vue-data-ui dev dependency before build --');
});
} else {
console.log(`Key '${keyToRemove}' not found in devDependencies.`);
}
});