2018-09-28 19:20:15 +00:00
|
|
|
const { basename, join, resolve } = require('path');
|
2019-05-14 12:03:11 +00:00
|
|
|
const fs = require('fs');
|
2018-09-28 19:20:15 +00:00
|
|
|
const { exec } = require('child_process');
|
|
|
|
|
|
|
|
const distDir = 'www/lib';
|
|
|
|
|
2019-05-14 12:03:11 +00:00
|
|
|
const filelist = fs.readFileSync('lib_list.txt', 'utf-8').split(/\r?\n/);
|
2018-09-28 19:20:15 +00:00
|
|
|
|
|
|
|
exec(`mkdir -p ${distDir}`, () => {
|
|
|
|
filelist.forEach(path => {
|
|
|
|
path = resolve(path);
|
|
|
|
const filename = basename(path);
|
2019-05-14 12:03:11 +00:00
|
|
|
const dest = fs.lstatSync(path).isDirectory()
|
2018-09-28 19:20:15 +00:00
|
|
|
? distDir
|
|
|
|
: join(distDir, filename);
|
|
|
|
const cmd = `rsync -ru ${path} ${dest}`;
|
|
|
|
console.log(cmd);
|
|
|
|
exec(cmd);
|
|
|
|
});
|
|
|
|
});
|
2019-05-14 12:03:11 +00:00
|
|
|
|
|
|
|
if (!fs.existsSync('src/config.json')) {
|
|
|
|
const cmd = `rsync -ru src/config.sample.json src/config.json`;
|
|
|
|
console.log(cmd);
|
|
|
|
exec(cmd);
|
|
|
|
}
|