refactoring
This commit is contained in:
20
copy_lib.js
Normal file
20
copy_lib.js
Normal file
@ -0,0 +1,20 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user