UNPKG

713 BJavaScriptView Raw
1let nodepath = require("path");
2let configOj = require("map-path")("Services/config.js");
3let cwd = process.cwd();
4let fs = require("fs-extra");
5
6function 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
26module.exports = config;