Skip to content

Commit 317450e

Browse files
authored
Merge pull request #312 from boonyarit-iamsaard/fix/version-preservation-in-release-process
Fix Version Discrepancy in CommonJS Compatibility Solution
2 parents 6cbf402 + 7605cf5 commit 317450e

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cron-validate",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "cron-validate is a cron-expression validator written in TypeScript.",
55
"scripts": {
66
"dev": "nodemon",
@@ -35,6 +35,7 @@
3535
"typescript"
3636
],
3737
"main": "lib/index.js",
38+
"type": "module",
3839
"types": "lib/index.d.ts",
3940
"files": [
4041
"lib"

scripts/remove-type.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ const packageJsonPath = './package.json'
55
// Read package.json
66
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
77

8+
// Store the semantic-release-generated version to ensure it's preserved during the process
9+
// This prevents the version from reverting to an older value when modifying package.json
10+
const currentVersion = packageJson.version
11+
812
// Remove "type" key for publishing
913
delete packageJson.type
1014

11-
// Write back package.json without "type" field
15+
// Ensure the version is preserved
16+
packageJson.version = currentVersion
17+
18+
// Write back package.json without "type" field but with version preserved
1219
writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`)

scripts/restore-type.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ const packageJsonPath = './package.json'
55
// Read current package.json (with new version)
66
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
77

8+
// Store the semantic-release-generated version to ensure it's preserved during the process
9+
// This prevents the version from reverting to an older value when modifying package.json
10+
const currentVersion = packageJson.version
11+
812
// Add back the "type" field
913
packageJson.type = 'module'
1014

11-
// Write back package.json with "type" field restored
15+
// Ensure the version is preserved
16+
packageJson.version = currentVersion
17+
18+
// Write back package.json with "type" field restored and version preserved
1219
writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`)

0 commit comments

Comments
 (0)