Skip to content

Commit

Permalink
fix: Fix invalid output checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Jense5 committed Feb 25, 2017
1 parent 4cc9c87 commit e455189
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (!commander.url) {

const rawOutputPath = commander.output || 'output.png';
const outputPath = path.resolve(process.cwd(), rawOutputPath);
const outputFile = path.extname(outputPath) === '.png' ? outputPath : `${outputPath}.png`;
const outputFile = path.extname(outputPath) === '.png' ? outputPath : path.resolve(outputPath, 'output.png');

winston.info(`Capturing ${chalk.cyan(commander.url)}`);
winston.info(`Writing to ${chalk.cyan(outputFile)}`);
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ const OPTIONS = { shotSize: { width: 'all', height: 'all' } };
* @param {string} outputPath The outputPath where the image should be written to
* @returns {Promise<string>} A promise that will create the image and returns the absolute path. */
export default (url: string, outputPath: string) => {
const absoluteOutputPath = path.resolve(process.cwd(), outputPath);
const aop = path.resolve(process.cwd(), outputPath);
const output = path.extname(aop) === '.png' ? aop : path.resolve(aop, 'output.png');
return new Promise((resolve, reject) => {
if (isUrl(url)) {
webshot(url, absoluteOutputPath, OPTIONS, (err) => {
webshot(url, output, OPTIONS, (err) => {
if (err) { reject(err); }
resolve(absoluteOutputPath);
resolve(output);
});
} else { reject('Invalid url provided.'); }
});
Expand Down

0 comments on commit e455189

Please sign in to comment.