2021-06-18 13:26:00 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
2021-10-07 07:30:02 +00:00
|
|
|
const { execSync, exec } = require('child_process');
|
2021-06-18 13:26:00 +00:00
|
|
|
|
|
|
|
let dirs = fs.readdirSync(path.resolve(__dirname, '../examples'));
|
|
|
|
|
|
|
|
dirs.forEach(dir => {
|
|
|
|
console.log(dir);
|
2021-10-07 07:30:02 +00:00
|
|
|
|
|
|
|
if (!isDir(path.resolve(__dirname, '../examples', dir,))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let num = 0;
|
|
|
|
if (isDir(path.resolve(__dirname, '../examples', dir, 'backend'))) {
|
|
|
|
++num;
|
|
|
|
process.chdir(path.resolve(__dirname, '../examples', dir, 'backend'));
|
|
|
|
execSync('ncu -u -t minor && npm i --registry https://registry.npm.taobao.org', { stdio: 'inherit' });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isDir(path.resolve(__dirname, '../examples', dir, 'frontend'))) {
|
|
|
|
++num;
|
|
|
|
process.chdir(path.resolve(__dirname, '../examples', dir, 'frontend'));
|
|
|
|
execSync('ncu -u -t minor && npm i --registry https://registry.npm.taobao.org', { stdio: 'inherit' });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!num) {
|
|
|
|
process.chdir(path.resolve(__dirname, '../examples', dir));
|
|
|
|
execSync('ncu -u -t minor && npm i --registry https://registry.npm.taobao.org', { stdio: 'inherit' });
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
function isDir(dir) {
|
|
|
|
return fs.existsSync(dir) && fs.statSync(dir).isDirectory()
|
|
|
|
}
|