mirror of
https://github.com/expo/dev-plugins.git
synced 2026-11-14 09:58:06 -10:00
42 lines
1.0 KiB
JavaScript
Executable File
42 lines
1.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const spawnAsync = require('@expo/spawn-async');
|
|
const fs = require('fs/promises');
|
|
const path = require('path');
|
|
|
|
const ROOT = path.resolve(__dirname, '..');
|
|
|
|
async function runAsync() {
|
|
const packageNames = (await fs.readdir(path.join(ROOT, 'packages'))).filter((name) =>
|
|
shouldPreparePackageAsync(name)
|
|
);
|
|
|
|
for (const packageName of packageNames) {
|
|
await prepareAsync(packageName);
|
|
}
|
|
}
|
|
|
|
async function shouldPreparePackageAsync(packageName) {
|
|
const packageJson = JSON.parse(
|
|
await fs.readFile(path.join(ROOT, 'packages', packageName, 'package.json'), 'utf8')
|
|
);
|
|
return !!packageJson.scripts?.prepare;
|
|
}
|
|
|
|
async function prepareAsync(packageName) {
|
|
console.log(`⚙️ Preparing package - ${packageName}`);
|
|
const packageRoot = path.join(ROOT, 'packages', packageName);
|
|
await spawnAsync('bun', ['run', 'prepare'], {
|
|
cwd: packageRoot,
|
|
});
|
|
}
|
|
|
|
(async () => {
|
|
try {
|
|
await runAsync();
|
|
} catch (e) {
|
|
console.error('Uncaught Error', e);
|
|
process.exit(1);
|
|
}
|
|
})();
|