You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

23 lines
629 B

const { execSync } = require('child_process');
const readline = require('readline');
// 写一个执行npm run migrate && npm run seed的脚本,当执行npm run seed时会谈提示是否重置数据
function run(command) {
execSync(command, { stdio: 'inherit' });
}
run('npx knex migrate:latest');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('是否重置数据?(y/N): ', (answer) => {
if (answer.trim().toLowerCase() === 'y') {
run('npx knex seed:run');
} else {
console.log('已取消数据重置。');
}
rl.close();
});