Skip to content

Commit

Permalink
Merge pull request #18 from ibarsi/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ibarsi authored Mar 5, 2017
2 parents a24578b + 7d1eca8 commit 4485751
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Project
**/node_modules
**/dist

# Git
**/.git

# Static files
**/node_modules

# Node
**/npm-debug.log

Expand Down
7 changes: 4 additions & 3 deletions main/modules/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
================================================== */

import fs from 'fs';
import os from 'os';

import { isFile } from './helpers';

export function Auth(token) {
return {
async isCredsTokenInitialized() {
return isFile(`${ process.env.HOME }/${ token }`);
return isFile(`${ os.homedir() }/${ token }`);
},
async getCreds() {
return JSON.parse(fs.readFileSync(`${ process.env.HOME }/${ token }`, 'utf8'));
return JSON.parse(fs.readFileSync(`${ os.homedir() }/${ token }`, 'utf8'));
},
storeCreds(username, password) {
return new Promise((resolve, reject) => {
fs.writeFile(
`${ process.env.HOME }/${ token }`,
`${ os.homedir() }/${ token }`,
JSON.stringify({ username, password }),
error => error ? reject(error) : resolve()
);
Expand Down

0 comments on commit 4485751

Please sign in to comment.