-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix): publish template resolver as a
cjs
package (#1045)
- Loading branch information
Showing
5 changed files
with
108 additions
and
101 deletions.
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
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,49 @@ | ||
const fs = require("fs"); | ||
|
||
// Function to update the version in package.json and remove "type": "module" | ||
function preparePackageJson(newVersion) { | ||
const packagePath = "./package.json"; | ||
|
||
// Read the package.json file | ||
fs.readFile(packagePath, "utf8", (err, data) => { | ||
if (err) { | ||
console.error(`Error reading package.json: ${err}`); | ||
return; | ||
} | ||
|
||
// Parse the JSON data | ||
let packageJson = JSON.parse(data); | ||
|
||
// Update the version | ||
packageJson.version = newVersion; | ||
|
||
// Remove the "type": "module" field if it exists | ||
if (packageJson.type === "module") { | ||
delete packageJson.type; | ||
} | ||
|
||
// Remove the "module" key if it exists | ||
if (packageJson["module"] != null) { | ||
delete packageJson.module; | ||
} | ||
|
||
// Write the updated package.json back to the file | ||
fs.writeFile(packagePath, JSON.stringify(packageJson, null, 2), (err) => { | ||
if (err) { | ||
console.error(`Error writing package.json: ${err}`); | ||
return; | ||
} | ||
|
||
console.log("package.json has been updated successfully."); | ||
}); | ||
}); | ||
} | ||
|
||
// Example usage: pass the new version as a command line argument | ||
const newVersion = process.argv[2]; | ||
if (!newVersion) { | ||
console.error("Please provide a version number as an argument."); | ||
process.exit(1); | ||
} | ||
|
||
preparePackageJson(newVersion); |
Oops, something went wrong.