Skip to content

Commit

Permalink
fix(cli): fixed the issue when output is not provided
Browse files Browse the repository at this point in the history
CLI has to save assets to the folder where the command is executed if no output-folder provided.

fix #1
  • Loading branch information
onderceylan committed Aug 14, 2019
1 parent 9e7f787 commit b7102e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 6 additions & 1 deletion cli.js
Expand Up @@ -68,7 +68,8 @@ const cli = meow(
},
);

const [source, output] = cli.input;
const source = cli.input[0];
let output = cli.input[1];
const options = cli.flags;
const logger = preLogger('cli');

Expand All @@ -77,6 +78,10 @@ if (!source) {
process.exit(1);
}

if (!output) {
output = process.cwd();
}

(async () => {
try {
const savedImages = await puppets.generateImages(source, output, options);
Expand Down
12 changes: 7 additions & 5 deletions helpers/pwa.js
Expand Up @@ -67,13 +67,15 @@ const addMetaTagsToIndexPage = async (htmlContent, indexHtmlFilePath) => {
throw Error(`Cannot write to index html file ${indexHtmlFilePath}`);
}

const warn = '<!-- AUTO GENERATED VIA PWA-ASSET-GENERATOR -->';

const indexHtmlFile = await file.readFile(indexHtmlFilePath);
const $ = cheerio.load(indexHtmlFile);
$('head').append(`\
${warn}
${htmlContent}`);

// TODO: Find a way to remove tags without leaving newlines behind
$(
'link[rel="apple-touch-startup-image"], link[rel="apple-touch-icon"], meta[name="apple-mobile-web-app-capable"]',
).remove();

$('head').append(`${htmlContent}`);

return file.writeFile(indexHtmlFilePath, $.html());
};
Expand Down

0 comments on commit b7102e7

Please sign in to comment.