Skip to content

Commit

Permalink
fix: pre + post release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
crherman7 committed May 21, 2024
1 parent f0809f0 commit b35f2db
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"build": "tsup",
"dev": "tsup --watch",
"prepare": "husky",
"release": "release-it"
"prerelease": "./remove-workspace",
"release": "release-it",
"postrelease": "./restore-workspace"
},
"release-it": {
"git": {
Expand Down
22 changes: 22 additions & 0 deletions scripts/remove-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/env node

const fs = require('fs');
const path = require('path');

const workingPath = process.cwd();

fs.copyFileSync(
path.resolve(workingPath, 'package.json'),
path.resolve('package.json.bak'),
);

const packageJson = JSON.parse(
fs.readFileSync(path.resolve(workingPath, 'package.json'), 'utf8'),
);

const {workspaces, ...packageJsonWithoutWorkspaces} = packageJson;

fs.writeFileSync(
path.resolve(workingPath, 'package.json'),
`${JSON.stringify(packageJsonWithoutWorkspaces, null, 2)}\n`,
);
10 changes: 10 additions & 0 deletions scripts/restore-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/env node

const fs = require('fs');

fs.copyFileSync(
path.resolve(workingPath, 'package.json.bak'),
path.resolve(workingPath, 'package.json'),
);

fs.unlinkSync(path.resolve(workingPath, 'package.json.bak'));

0 comments on commit b35f2db

Please sign in to comment.