Skip to content

Commit 8aad058

Browse files
authored
fix: restorePackageJson failure after stopping toolkit extension (aws#5262)
Problem: - When debugging toolkit the tasks rely on the restorePackageJson script that was removed in aws#5222 Solution: - Re-add the restorePackageJson script
1 parent b0eb729 commit 8aad058

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

packages/toolkit/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
"createRelease": "ts-node ../../scripts/createRelease.ts",
7272
"newChange": "ts-node ../../scripts/newChange.ts",
7373
"watch": "npm run clean && npm run buildScripts && tsc -watch -p ./",
74-
"copyPackageJson": "ts-node ./scripts/build/handlePackageJson"
74+
"copyPackageJson": "ts-node ./scripts/build/handlePackageJson",
75+
"restorePackageJson": "ts-node ./scripts/build/handlePackageJson --restore"
7576
},
7677
"devDependencies": {},
7778
"dependencies": {

packages/toolkit/scripts/build/handlePackageJson.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
* TODO: IDE-12831 tracks work to eliminate this script.
1414
*
1515
* Args:
16-
* --restore: (XXX: this mode was inlined into the package.ts script.)
16+
* --restore: reverts the package json changes to the original state
1717
* --development: performs actions that should only be done during development and not production
1818
*/
1919

2020
import * as fs from 'fs-extra'
2121

2222
function main() {
2323
const args = process.argv.slice(2)
24-
// XXX: --restore mode was inlined into the package.ts script.
25-
const restoreMode = false
24+
const restoreMode = args.includes('--restore')
2625

2726
if (args.includes('--development')) {
2827
/** When we actually package the extension the null extension does not occur, so we will skip this hack */
@@ -34,14 +33,13 @@ function main() {
3433
const coreLibPackageJsonFile = '../core/package.json'
3534

3635
if (restoreMode) {
37-
// XXX: --restore mode was inlined into the package.ts script.
3836
// TODO: IDE-12831 will eliminate this entire script.
39-
// try {
40-
// fs.copyFileSync(backupJsonFile, packageJsonFile)
41-
// fs.unlinkSync(backupJsonFile)
42-
// } catch (err) {
43-
// console.log(`Could not restore package.json. Error: ${err}`)
44-
// }
37+
try {
38+
fs.copyFileSync(backupJsonFile, packageJsonFile)
39+
fs.unlinkSync(backupJsonFile)
40+
} catch (err) {
41+
console.log(`Could not restore package.json. Error: ${err}`)
42+
}
4543
} else {
4644
fs.copyFileSync(packageJsonFile, backupJsonFile)
4745
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile, { encoding: 'utf-8' }))

0 commit comments

Comments
 (0)