Skip to content

Commit c836d3a

Browse files
committed
fix: Update file dependency version and add console colors, minor code refactoring to CoCreate Config.
1 parent 562a6e3 commit c836d3a

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
},
6060
"dependencies": {
6161
"@cocreate/docs": "^1.8.2",
62-
"@cocreate/file": "^1.0.0",
62+
"@cocreate/file": "^1.1.0",
6363
"colors": "latest",
6464
"glob": "^7.1.7",
6565
"prettier": "^2.3.2"
6666
}
67-
}
67+
}

src/coc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
#!/usr/bin/env node
1+
#!/usr/bin/env node
22
const path = require("path");
33
const fs = require("fs");
44
const execute = require('./execute');
55
const argv = process.argv.slice(2);
66
const addMeta = require('./addMeta');
7+
const colors = require('colors');
78

89

910
if (argv.length < 1) {
@@ -57,7 +58,7 @@ if (config['c'] && fs.existsSync(config['c'])) {
5758
}];
5859
directory = path.dirname(packageJsonPath);
5960
console.warn(`using ${packageJsonPath} configuration`.yellow);
60-
}
61+
}
6162
// else {
6263
// console.error(`a configuration file can not be found`.red);
6364
// process.exit(1);

src/commands/config.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,28 @@ module.exports = async function CoCreateConfig(items, processEnv = true, updateG
4040
items = [items];
4141
}
4242
for (let i = 0; i < items.length; i++) {
43-
const { key, prompt, choices } = items[i];
43+
let { key, prompt, choices } = items[i];
4444
if (!key) {
4545
if (!prompt && prompt !== '' || !choices) continue;
46+
for (let choice of Object.keys(choices)) {
47+
// if (!Array.isArray(choiceItems)) {
48+
// choiceItems = [choiceItems];
49+
// }
50+
// for (let choice of choiceItems) {
51+
let choiceKey = choices[choice].key
52+
if (process.env[choiceKey]) {
53+
config[choiceKey] = process.env[choiceKey];
54+
return;
55+
} else if (localConfig[choiceKey]) {
56+
config[choiceKey] = localConfig[choiceKey];
57+
return;
58+
59+
} else if (globalConfig[choiceKey]) {
60+
config[choiceKey] = globalConfig[choiceKey];
61+
return;
62+
}
63+
}
64+
// }
4665
const answer = await promptForInput(prompt || `${key}: `);
4766
const choice = choices[answer];
4867
if (choice) {

src/commands/upload.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
const crud = require('@cocreate/crud-client')
2-
const mime = require('mime-types')
3-
const fs = require('fs');
41
const file = require('@cocreate/file')
52

63
module.exports = async function upload(repos, args) {

0 commit comments

Comments
 (0)