Skip to content

Commit

Permalink
Fix clasp logout (google#164)
Browse files Browse the repository at this point in the history
It now removes .clasprc.json file in the users current directory

Signed-off-by: campionfellin <[email protected]>
  • Loading branch information
campionfellin authored and grant committed May 14, 2018
1 parent aa99038 commit 0080f67
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ commander
.description('Log out')
.action(() => {
del(DOT.RC.ABSOLUTE_PATH, { force: true }); // del doesn't work with a relative path (~)
del(DOT.RC.ABSOLUTE_LOCAL_PATH, { force: true });
});

/**
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const DOT = {
NAME: `${PROJECT_NAME}rc.json`,
PATH: path.join('~', `.${PROJECT_NAME}rc.json`),
ABSOLUTE_PATH: path.join(os.homedir(), `.${PROJECT_NAME}rc.json`),
ABSOLUTE_LOCAL_PATH: path.join('.', `.${PROJECT_NAME}rc.json`),
},
};

Expand Down
5 changes: 3 additions & 2 deletions tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { describe, it } from 'mocha';
import { expect } from 'chai';
import * as fs from 'fs';
import * as os from 'os';

const { spawnSync } = require('child_process');
import { getScriptURL, getFileType, getAPIFileType,
saveProjectId } from './../src/utils.js';
Expand Down Expand Up @@ -202,11 +204,10 @@ describe('Test saveProjectId function from utils', () => {
});
});

// Fails when you logged in using --ownkey flag
describe.skip('Test clasp logout function', () => {
it('should logout correctly', () => {
fs.writeFileSync('.clasprc.json', ' ');
fs.writeFileSync('~/.clasprc.json', ' ');
fs.writeFileSync(path.join(os.homedir(), '/.clasprc.json'), ' ');
const result = spawnSync(
'clasp', ['logout'], { encoding: 'utf8' },
);
Expand Down

0 comments on commit 0080f67

Please sign in to comment.