mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 13:16:03 +08:00
Build: Adds a fallback script to fix package.json main and types fields before packaging (#59628)
This commit is contained in:
21
scripts/prepare-packagejson.js
Normal file
21
scripts/prepare-packagejson.js
Normal file
@ -0,0 +1,21 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const cwd = process.cwd();
|
||||
const packageJson = require(`${cwd}/package.json`);
|
||||
|
||||
const newPackageJson = {
|
||||
...packageJson,
|
||||
main: packageJson.publishConfig?.main ?? packageJson.main,
|
||||
};
|
||||
|
||||
if (packageJson.publishConfig?.types) {
|
||||
newPackageJson.types = packageJson.publishConfig.types;
|
||||
}
|
||||
|
||||
if (packageJson.publishConfig?.module) {
|
||||
newPackageJson.module = packageJson.publishConfig.module;
|
||||
}
|
||||
|
||||
try {
|
||||
fs.writeFileSync(`${cwd}/package.json`, JSON.stringify(newPackageJson, null, 2));
|
||||
} catch (e) {}
|
Reference in New Issue
Block a user