Skip to content

Commit

Permalink
fixed bug where can't write to nonexistent lib folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Gesoff committed Mar 24, 2016
1 parent c42c060 commit 245ba01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ GLOBAL.XMLHttpRequest = require('xmlhttprequest-cookie').XMLHttpRequest;
GLOBAL.Promise = require('es6-promise-polyfill').Promise;
GLOBAL.WebSocket = require('websocket').w3cwebsocket;

var apiFile = __dirname + '/lib/api.js';
var apiFile = __dirname + '/api.js';

module.exports = (function() {
if(!fs.existsSync(apiFile)) {
if(!fs.existsSync(__dirname + '/../../lib/api.js')) {
if(!fs.existsSync(__dirname + '/../../api.js')) {
throw new Error('api.js does not exist! (Have you downloaded it using updateAPI.js?)');
}
else {
apiFile = __dirname + '/../../lib/api.js';
apiFile = __dirname + '/../../api.js';
}
}
var api = fs.readFileSync(apiFile, 'utf8');
Expand Down
2 changes: 1 addition & 1 deletion updateAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function getAPI(host, callback) {
return;
}
try {
fs.writeFileSync(__dirname + '/lib/api.js', body);
fs.writeFileSync(__dirname + '/api.js', body);
//console.log('Successfully written api.js');
if(typeof callback == 'function') {
callback(null);
Expand Down

0 comments on commit 245ba01

Please sign in to comment.