Skip to content

Commit

Permalink
Fix notify option, move function up
Browse files Browse the repository at this point in the history
  • Loading branch information
jsines committed Oct 18, 2023
1 parent 23f6096 commit ffdd34c
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions packages/cli/commands/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ const { trackCommandUsage } = require('../lib/usageTracking');

const i18nKey = 'cli.commands.preview';

const validateSrcPath = src => {
const logInvalidPath = () => {
logger.log(
i18n(`${i18nKey}.errors.invalidPath`, {
path: src,
})
);
};
try {
const stats = fs.statSync(src);
if (!stats.isDirectory()) {
logInvalidPath();
return false;
}
} catch (e) {
logInvalidPath();
return false;
}
return true;
};

exports.command = 'preview <src> <dest>';
exports.describe = i18n(`${i18nKey}.describe`);

Expand Down Expand Up @@ -47,26 +68,11 @@ exports.builder = yargs => {
describe: i18n(`${i18nKey}.options.initialUpload.describe`),
type: 'boolean',
});
yargs.option('notify', {
alias: 'n',
describe: i18n(`${i18nKey}.options.notify.describe`),
type: 'string',
requiresArg: true,
});
return yargs;
};

const validateSrcPath = src => {
const logInvalidPath = () => {
logger.log(
i18n(`${i18nKey}.errors.invalidPath`, {
path: src,
})
);
};
try {
const stats = fs.statSync(src);
if (!stats.isDirectory()) {
logInvalidPath();
return false;
}
} catch (e) {
logInvalidPath();
return false;
}
return true;
};

0 comments on commit ffdd34c

Please sign in to comment.