Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Add a better error message when uploading without a zip
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Gardner committed Mar 15, 2019
1 parent b688200 commit 716b112
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/commands/upload.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
const colors = require('colors/safe');
const constants = require('../constants');
const utils = require('../utils');

const upload = context => {
context.line('Preparing to upload a new version.\n');
return utils.upload().then(() => {
const upload = async context => {
try {
context.line('Preparing to upload a new version.\n');
await utils.upload();

context.line(
`\nUpload of ${constants.BUILD_PATH} and ${
constants.SOURCE_PATH
} complete! Try \`zapier versions\` now!`
);
});
} catch (error) {
context.line(`${colors.red('Problem uploading:')} ${error.message}`);
}
};
upload.argsSpec = [];
upload.argOptsSpec = {};
Expand Down
2 changes: 1 addition & 1 deletion src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module.exports = argv => {
process.exit(1);
}

commandFunc.apply(commands, [context].concat(args)).catch(err => {
commandFunc(context, ...args).catch(err => {
utils.endSpinner(false);

if (DEBUG || global.argOpts.debug) {
Expand Down
7 changes: 7 additions & 0 deletions src/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ const upload = (zipPath, sourceZipPath, appDir) => {

const fullZipPath = path.resolve(appDir, zipPath);
const fullSourceZipPath = path.resolve(appDir, sourceZipPath);
const isMissingZip = !fs.existsSync(fullZipPath);

if (isMissingZip) {
throw new Error(
'Missing a built app. Try running `zapier build` first.\nOr you could run `zapier push`, which will build and upload in one command.'
);
}

return getLinkedApp(appDir)
.then(app => {
Expand Down

0 comments on commit 716b112

Please sign in to comment.