INNER CODE UNIT · JavaScript
fail
reactnativecn/react-native-update · scripts/build-harmony-har.js:492
function fail(message) {
throw new Error(message);
}
function hasDependencies(dir) {
try {
const pkgPath = path.join(dir, 'oh-package.json5');
if (!fs.existsSync(pkgPath)) {
return false;
}
const pkgContent = fs.readFileSync(pkgPath, 'utf8');
const cleanJson = pkgContent.replace(
/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,
''
);
const pkg = eval('(' + cleanJson + ')');
const hasDeps =
pkg.dependencies && Object.keys(pkg.dependencies).length > 0;