Skip to content

Commit

Permalink
Merge pull request #7 from FilosofiaCodigo/main
Browse files Browse the repository at this point in the history
Following a common standard
  • Loading branch information
NotLuksus authored Aug 25, 2021
2 parents 22bcff7 + 42dac68 commit baad831
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,15 @@ async function metadataSettings() {
name: 'metadataImageUrl',
message: 'What should be the image url? (Generated format is URL/ID)',
},
{
type: 'confirm',
name: 'splitFiles',
message: 'Should JSON metadata be split in multiple files?',
},
]);
config.metaData.name = responses.metadataName;
config.metaData.description = responses.metadataDescription;
config.metaData.splitFiles = responses.splitFiles;
let lastChar = responses.metadataImageUrl.slice(-1);
if (lastChar === '/') config.imageUrl = responses.metadataImageUrl;
else config.imageUrl = responses.metadataImageUrl + '/';
Expand Down Expand Up @@ -425,7 +431,19 @@ function generateMetadataObject(id, images) {
}

async function writeMetadata() {
await writeFile(outputPath + 'metadata.json', JSON.stringify(metaData));
if(config.metaData.splitFiles)
{
let metadata_output_dir = outputPath + "metadata/"
if (!fs.existsSync(metadata_output_dir)) {
fs.mkdirSync(metadata_output_dir, { recursive: true });
}
for (var key in metaData){
await writeFile(metadata_output_dir + key, JSON.stringify(metaData[key]));
}
}else
{
await writeFile(outputPath + 'metadata.json', JSON.stringify(metaData));
}
}

async function loadConfig() {
Expand Down

0 comments on commit baad831

Please sign in to comment.