INNER CODE UNIT · TypeScript

readVersionName

reactnativecn/react-native-update · harmony/hvigor-plugin.ts:34

function readVersionName(projectDir: string): string {
  const appJsonPath = path.resolve(projectDir, 'AppScope/app.json5');
  if (!fs.existsSync(appJsonPath)) {
    return '';
  }
  const content = fs.readFileSync(appJsonPath, 'utf-8');
  const match = content.match(
    /(?:"versionName"|versionName):\s*["']([^"']+)["']/,
  );
  return match?.[1] || '';
}

// Only `hvigorw assemble{Hap,App,Hsp,Har}` (DevEco's Build/Run actions pass
// the same task) should touch the consumer's source tree; IDE sync
// (`--sync`), `clean` and friends must not rewrite meta.json.
export function isAssembleInvocation(argv: string[]): boolean {
  return argv.some(arg => /^assemble/i.test(arg));
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…