hubl/copy_lib.js

21 lines
564 B
JavaScript
Raw Normal View History

2018-09-28 19:20:15 +00:00
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);
});
});