-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove prepublish script when creating template with Semaphore …
…CLI (#882) * feat(cli): remove @semaphore-protocol/cli prepublish script The idea is to remove the prepublish script from the scripts object of the package.json file of every cli template when the template is downloaded using the CLI. BREAKING CHANGE: n * refactor(cli): add comment * refactor(cli): create seperate file for removePrePublishScript function * refactor(cli): using updatedPackageJsonContent var instead of calling readFileSync again
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Remove the prepublish script from the package.json file when creating a new project using the Semaphore CLI. | ||
export default function removePrePublishScript(packageJsonContent: string): string { | ||
try { | ||
const packageJson = JSON.parse(packageJsonContent) | ||
if (packageJson.scripts && "prepublish" in packageJson.scripts) { | ||
delete packageJson.scripts.prepublish | ||
if (Object.keys(packageJson.scripts).length === 0) { | ||
delete packageJson.scripts | ||
} | ||
} | ||
return JSON.stringify(packageJson, null, 2) | ||
} catch (error) { | ||
console.error("Error processing package.json:", error) | ||
return packageJsonContent | ||
} | ||
} |