forked from shlomiassaf/ng-cli-packagr-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy-files.ts
24 lines (22 loc) · 824 Bytes
/
copy-files.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* Example: Copy the `LICENSE` file to the root of every package
*
* This can be extended to support complex copy instruction passed through `transformData`
*/
import * as Path from 'path';
import * as FS from 'fs';
import { NgPackagerTransformerHooks, NgPackagerTransformerHooksContext } from 'ng-cli-packagr-tasks';
module.exports = function(ctx: NgPackagerTransformerHooksContext) {
const hooks: NgPackagerTransformerHooks = {
writePackage: {
after: async taskContext => {
const srcFile = Path.join(ctx.root, 'LICENSE');
const dstFile = Path.join(taskContext.epNode.data.entryPoint.destinationPath, 'LICENSE');
return new Promise<void>( (res, rej) => {
FS.copyFile(srcFile, dstFile, err => err ? rej(err) : res());
});
}
},
};
return hooks;
}