Added angular-librarian for manage library
This commit is contained in:
parent
9d174550f5
commit
e625f9fd30
44 changed files with 1867 additions and 228 deletions
35
tasks/copy-globs.js
Normal file
35
tasks/copy-globs.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs-extra');
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
|
||||
const copy = (globs, from, to) => {
|
||||
if (typeof globs === 'string') {
|
||||
globs = [globs];
|
||||
}
|
||||
|
||||
fs.ensureDir(to);
|
||||
return Promise.all(
|
||||
globs.map((fileGlob) => copyGlob(fileGlob, from, to))
|
||||
);
|
||||
};
|
||||
|
||||
const copyGlob = (fileGlob, from, to) => new Promise((resolve, reject) => {
|
||||
glob(fileGlob, { cwd: from, nodir: true }, (error, files) => {
|
||||
if (error) reject(error);
|
||||
|
||||
files.forEach((file) => {
|
||||
const origin = path.resolve(from, file);
|
||||
const destination = path.resolve(to, file);
|
||||
const contents = fs.readFileSync(origin, 'utf8');
|
||||
|
||||
fs.ensureDirSync(path.dirname(destination));
|
||||
fs.writeFileSync(destination, contents);
|
||||
});
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = copy;
|
||||
Loading…
Add table
Add a link
Reference in a new issue