MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / modifyPackageJson

Function modifyPackageJson

scripts/prepublish.ts:77–105  ·  view source on GitHub ↗
({
  version,
}: {
  version: string;
})

Source from the content-addressed store, hash-verified

75}
76
77async function modifyPackageJson({
78 version,
79}: {
80 version: string;
81}): Promise<void> {
82 const packageJsonPath = path.join(__dirname, '..', 'package.json');
83
84 try {
85 await access(packageJsonPath);
86 } catch {
87 throw new Error(`package.json not found at ${packageJsonPath}`);
88 }
89
90 console.log('Reading package.json...');
91 const packageJsonContent = await readFile(packageJsonPath, 'utf-8');
92 const packageJson = JSON.parse(packageJsonContent);
93
94 packageJson.version = version;
95
96 console.log('Writing modified package.json...');
97
98 await writeFile(
99 packageJsonPath,
100 JSON.stringify(packageJson, null, 2),
101 'utf-8',
102 );
103
104 console.log('package.json has been modified for publishing');
105}
106
107function isGitHubCI(): boolean {
108 return process.env.GITHUB_ACTIONS === 'true';

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected