UNPKG

1.58 kBJavaScriptView Raw
1var $, i, j, key, len, len1, listLazyModule, listLazyTask, path;
2
3path = require('path');
4
5$ = {};
6
7// inject module
8listLazyModule = ['_watch', 'argv', 'backup_', 'build_', 'chain', 'clean_', 'compile_', 'copy_', 'delay_', 'download_', 'exec_', 'fetchGithub_', 'formatArgument', 'getBasename', 'getDirname', 'getExtname', 'getFilename', 'getName', 'home', 'i', 'info', 'isExisted_', 'isSame_', 'link_', 'lint_', 'mkdir_', 'move_', 'normalizePath', 'normalizePathToArray', 'os', 'parseJson', 'parseString', 'prompt_', 'read_', 'recover_', 'reload', 'remove_', 'rename_', 'require', 'root', 'say_', 'source_', 'ssh', 'stat_', 'task', 'type', 'walk_', 'watch', 'wrapList', 'write_', 'zip_'];
9
10for (i = 0, len = listLazyModule.length; i < len; i++) {
11 key = listLazyModule[i];
12 (function(key) {
13 // function
14 return $[key] = !key.endsWith('_') ? function(...arg) {
15 $[key] = require(path.resolve(__dirname, `./dist/${key}.js`));
16 return $[key](...arg);
17 // async function
18 } : async function(...arg) {
19 $[key] = require(path.resolve(__dirname, `./dist/${key}.js`));
20 return (await $[key](...arg));
21 };
22 })(key);
23}
24
25// inject task
26listLazyTask = ['build','default','gurumin','kokoro','lint','noop','prune','update','watch'];
27
28for (j = 0, len1 = listLazyTask.length; j < len1; j++) {
29 key = listLazyTask[j];
30 (function(key) {
31 return $.task(key, async function(...arg) {
32 var fn_;
33 fn_ = require(path.resolve(__dirname, `./dist/task/${key}`));
34 return (await fn_(...arg));
35 });
36 })(key);
37}
38
39// return
40module.exports = $;