Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit c014793

Browse files
authored
Merge pull request #68 from perry-mitchell/master
Fix absolute paths
2 parents 8f0d12f + 6fed61b commit c014793

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

bin/modules/validateAddPackages.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55
*/
66
"use strict";
77
const fs = require("fs");
8+
const path = require("path");
89
const removeAllFromStr = require("../utils/removeAllFromStr");
910
const isJsonString = require("../utils/isJsonString");
1011

1112
// Not using arrows bc it will mess up "this" context
12-
module.exports = function (path) {
13+
module.exports = function (jsonPath) {
1314
// Declare function as asynchronous, and save the done callback
1415
let done = this.async();
1516
try {
16-
if (path.indexOf(".json") < 0) {
17+
if (jsonPath.indexOf(".json") < 0) {
1718
done("Not a JSON file");
1819
return;
1920
}
20-
let packagePath = path.indexOf("/") === 0 ? path.replace("/","") : path;
21-
let fullPath = process.cwd() + "/" + removeAllFromStr( packagePath, [ "`", '"', "'" ] )
21+
// Calculate the full path of the JSON file based upon the current working directory. Using
22+
// path.resolve allows for absolute paths to be used also.
23+
let fullPath = path.resolve(process.cwd(), jsonPath);
2224
fs.readFile(fullPath, (err, data) => {
2325
if (err){ done(err); return; }
2426
if (isJsonString(data)) {

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"name": "git-labelmaker",
33
"version": "0.8.0",
44
"description": "Manage your GitHub labels from the command line! ",
5-
"main": "index.js",
5+
"main": "bin/index.js",
66
"scripts": {
7+
"start": "./bin/index.js",
78
"test": "echo No tests"
89
},
910
"repository": {
@@ -31,7 +32,7 @@
3132
},
3233
"homepage": "https://github.com/himynameisdave/git-labelmaker#readme",
3334
"dependencies": {
34-
"buttercup": "0.17.0",
35+
"buttercup": "~0.24.0",
3536
"git-label": "^4.1.1",
3637
"github-url-from-git": "^1.4.0",
3738
"inquirer": "^0.11.1",

0 commit comments

Comments
 (0)