Skip to content

Commit

Permalink
Fix Issue google#211 by unwrapping data after checking for an error. (g…
Browse files Browse the repository at this point in the history
…oogle#213)

Signed-off-by: campionfellin <[email protected]>
  • Loading branch information
campionfellin authored and grant committed Jun 6, 2018
1 parent d8a017d commit 88f8e33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ export async function fetchProject(scriptId: string, rootDir = '', versionNumber
script.projects.getContent({
scriptId,
versionNumber,
}, {}, (error: any, { data }: any) => {
}, {}, (error: any, res: any) => {
spinner.stop(true);
if (error) {
if (error.statusCode === 404) return logError(null, ERROR.SCRIPT_ID_INCORRECT(scriptId));
return logError(error, ERROR.SCRIPT_ID);
} else {
const data = res.data;
if (!data.files) {
return logError(null, ERROR.SCRIPT_ID_INCORRECT(scriptId));
}
Expand Down
7 changes: 7 additions & 0 deletions tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ describe.skip('Test clasp clone <scriptId> function', () => {
expect(result.stdout).to.contain('files.');
expect(result.status).to.equal(0);
});
it('should give an error on a non-existing project', () => {
const result = spawnSync(
'clasp', ['clone', 'non-existing-project'], { encoding: 'utf8' },
);
expect(result.stderr).to.contain('> Did you provide the correct scriptId?');
expect(result.status).to.equal(1);
});
});

describe.skip('Test clasp pull function', () => {
Expand Down

0 comments on commit 88f8e33

Please sign in to comment.