Skip to content

Commit

Permalink
Merge pull request #55 from nunocoracao/54-cant-add-homepage-image-if…
Browse files Browse the repository at this point in the history
…-assets-folder-doesnt-exists

🐛 Can't add homepage image if assets folder doesn't exists
  • Loading branch information
nunocoracao authored Feb 10, 2024
2 parents 1a176d7 + 7f528da commit d2551ab
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
4 changes: 2 additions & 2 deletions configs/configOptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
},
{
"text": "Site's logo",
"method": "configLoop",
"method": "configImage",
"file": "./config/_default/languages.en.toml",
"parent": "params",
"key": "logo",
"description": "Site's logo, the logo file should be provided at 2x resolution and supports any image dimensions."
},
{
"text": "Site's secondary logo",
"method": "configLoop",
"method": "configImage",
"file": "./config/_default/languages.en.toml",
"parent": "params",
"key": "secondaryLogo",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blowfish-tools",
"version": "1.0.0",
"version": "1.1.0",
"description": "CLI to initialize and configure a Blowfish project.",
"main": "cli.js",
"bin": {
Expand Down
57 changes: 35 additions & 22 deletions src/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,19 +427,32 @@ export default class flow {
process.exit(0);
}

utils.run('cp ' + newValue + ' ./assets/', false);
newValue = newValue.split('/').pop();

if (!parent) {
data[variable] = newValue
} else if (data[parent]) {
data[parent][variable] = newValue
var processChanges = () => {
utils.run('cp ' + newValue + ' ./assets/', false);
newValue = newValue.split('/').pop();

if (!parent) {
data[variable] = newValue
} else if (data[parent]) {
data[parent][variable] = newValue
} else {
data[parent] = {}
data[parent][variable] = newValue
}

utils.saveFileSync(file, toml.stringify(data));
}

if (!utils.directoryExists('./assets/')) {
utils.run('mkdir assets', false)
.then(() => {
processChanges()
});
} else {
data[parent] = {}
data[parent][variable] = newValue
processChanges()
}

utils.saveFileSync(file, toml.stringify(data));
}

static async configMenus(file) {
Expand Down Expand Up @@ -845,7 +858,7 @@ var exitOption = {

var configOptionsJSONList = utils.readAppJsonConfig('configOptions.json');

function createAction (method, file, parent, key, description) {
function createAction(method, file, parent, key, description) {
return async (list) => {
await flow[method](
file,
Expand Down Expand Up @@ -894,11 +907,11 @@ var options = [

var tempList = []
for (var i in configOptions) {
if (configOptions[i].parent === null || configOptions[i].method === 'exit'){
if (configOptions[i].parent === null || configOptions[i].method === 'exit') {

}

tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand All @@ -912,7 +925,7 @@ var options = [
var tempList = []
for (var i in configOptions) {
if (configOptions[i].parent === 'author' || configOptions[i].method === 'exit')
tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand All @@ -926,7 +939,7 @@ var options = [
var tempList = []
for (var i in configOptions) {
if (configOptions[i].parent === "homepage" || configOptions[i].method === 'exit')
tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand All @@ -940,7 +953,7 @@ var options = [
var tempList = []
for (var i in configOptions) {
if (configOptions[i].parent === "header" || configOptions[i].method === 'exit')
tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand All @@ -954,7 +967,7 @@ var options = [
var tempList = []
for (var i in configOptions) {
if (configOptions[i].parent === "footer" || configOptions[i].method === 'exit')
tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand All @@ -968,7 +981,7 @@ var options = [
var tempList = []
for (var i in configOptions) {
if (configOptions[i].parent === "article" || configOptions[i].method === 'exit')
tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand All @@ -982,7 +995,7 @@ var options = [
var tempList = []
for (var i in configOptions) {
if (configOptions[i].parent === "list" || configOptions[i].method === 'exit')
tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand All @@ -996,7 +1009,7 @@ var options = [
var tempList = []
for (var i in configOptions) {
if (configOptions[i].parent === "taxonomy" || configOptions[i].method === 'exit')
tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand All @@ -1010,7 +1023,7 @@ var options = [
var tempList = []
for (var i in configOptions) {
if (configOptions[i].parent === "term" || configOptions[i].method === 'exit')
tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand All @@ -1024,7 +1037,7 @@ var options = [
var tempList = []
for (var i in configOptions) {
if (configOptions[i].method === "configImage" || configOptions[i].method === 'exit')
tempList.push(configOptions[i])
tempList.push(configOptions[i])
}

flow.enterConfigMode(tempList);
Expand Down
1 change: 1 addition & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default class utils {
try {
return fs.existsSync(path);
} catch (err) {
console.log(err)
return false;
}
}
Expand Down

0 comments on commit d2551ab

Please sign in to comment.