21 lines
564 B
JavaScript
21 lines
564 B
JavaScript
const { basename, join, resolve } = require('path');
|
|
const { readFileSync, lstatSync } = require('fs');
|
|
const { exec } = require('child_process');
|
|
|
|
const distDir = 'www/lib';
|
|
|
|
const filelist = readFileSync('lib_list.txt', 'utf-8').split(/\r?\n/);
|
|
|
|
exec(`mkdir -p ${distDir}`, () => {
|
|
filelist.forEach(path => {
|
|
path = resolve(path);
|
|
const filename = basename(path);
|
|
const dest = lstatSync(path).isDirectory()
|
|
? distDir
|
|
: join(distDir, filename);
|
|
const cmd = `rsync -ru ${path} ${dest}`;
|
|
console.log(cmd);
|
|
exec(cmd);
|
|
});
|
|
});
|