Skip to content

Commit

Permalink
style: revert additional formatting changes (will be done in a separa…
Browse files Browse the repository at this point in the history
…te PR)
  • Loading branch information
emmenko committed Jan 18, 2017
1 parent cb3e835 commit a8ef94b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
16 changes: 7 additions & 9 deletions src/ApiDataCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,30 @@ import mkdirp from "mkdirp";
import ConfigurationError from "./ConfigurationError";

export default class ApiDataCache {
constructor(host, { rootPath, cacheDir }) {
constructor(host, {rootPath, cacheDir}) {
this.host = host;
const dir = this.dir = cacheDir && path.join(rootPath, cacheDir, host);

if (dir) {
try {
mkdirp.sync(dir);
} catch (e) {
throw new ConfigurationError(
`Can't use cacheDir "${cacheDir}" (${e.message})`
);
throw new ConfigurationError(`Can't use cacheDir "${cacheDir}" (${e.message})`);
}
}
}

get(type, key) {
if (!this.dir)
return;
if (!this.dir) return;
try {
return fs.readFileSync(this.fn(type, key), "utf-8");
} catch (e) {}
} catch (e) {
// Pass.
}
}

set(type, key, data) {
if (!this.dir)
return;
if (!this.dir) return;
return fs.writeFileSync(this.fn(type, key), data);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ConfigurationError.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Gotta do this the old-fashioned way. :p
//
export default function ConfigurationError(message) {
this.name = "ConfigurationError";
this.name = 'ConfigurationError';
this.message = message;
this.stack = new Error().stack;
this.stack = (new Error()).stack;
}
ConfigurationError.prototype = Object.create(Error.prototype);
ConfigurationError.prototype.constructor = ConfigurationError;
20 changes: 7 additions & 13 deletions src/GithubAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import ConfigurationError from "./ConfigurationError";

export default class GithubAPI {
constructor(config) {
const { repo } = config;
const {repo} = config;
this.repo = repo;
this.cache = new ApiDataCache("github", config);
this.cache = new ApiDataCache('github', config);
this.auth = process.env.GITHUB_AUTH;
if (!this.auth) {
throw new ConfigurationError("Must provide GITHUB_AUTH");
}
}

getIssueData(issue) {
return this._get("issue", issue);
return this._get('issue', issue);
}

getUserData(login) {
return this._get("user", login);
return this._get('user', login);
}

_get(type, key) {
Expand All @@ -32,16 +32,10 @@ export default class GithubAPI {

_fetch(type, key) {
const path = {
issue: `/repos/${this.repo}/issues/${key}`,
user: `/users/${key}`
issue : `/repos/${this.repo}/issues/${key}`,
user : `/users/${key}`
}[type];
const url = "https://api.github.com" + path;
return execSync(
"curl " +
"--silent " +
"--globoff " +
"-H 'Authorization: token " + process.env.GITHUB_AUTH + "' " +
url
);
return execSync("curl -H 'Authorization: token " + process.env.GITHUB_AUTH + "' --silent --globoff " + url)
}
}
2 changes: 1 addition & 1 deletion src/RemoteRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import GithubAPI from "./GithubAPI";

export default class RemoteRepo {
constructor(config) {
const { repo, labels } = config;
const {repo, labels} = config;
this.repo = repo;
this.labels = labels;
this.githubAPI = new GithubAPI(config);
Expand Down
4 changes: 3 additions & 1 deletion src/execSync.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import child from "child_process";

export default function execSync(cmd) {
return child.execSync(cmd, { encoding: "utf8" }).trim();
return child.execSync(cmd, {
encoding: "utf8"
}).trim();
}

0 comments on commit a8ef94b

Please sign in to comment.