1 | let nodepath = require("path");
|
2 | let configOj = require("map-path")("Services/config.js");
|
3 | let cwd = process.cwd();
|
4 | let fs = require("fs-extra");
|
5 |
|
6 | function config(url) {
|
7 | let newUrl = url;
|
8 |
|
9 | if (!nodepath.isAbsolute(url)) {
|
10 | newUrl = nodepath.join(cwd, url);
|
11 | }
|
12 | return new Promise((resolve, reject) => {
|
13 | fs.writeJson(configOj.configUrl, { path: newUrl })
|
14 | .then(() => {
|
15 | fs.ensureDirSync(newUrl);
|
16 | fs.ensureDirSync(nodepath.join(newUrl, "cmds"));
|
17 | fs.ensureDirSync(nodepath.join(newUrl, "tasks"));
|
18 | resolve(`${newUrl} is config to store action`);
|
19 | })
|
20 | .catch(err => {
|
21 | reject(err);
|
22 | });
|
23 | });
|
24 | }
|
25 |
|
26 | module.exports = config;
|