Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/upstream/master' into global-pa…
…ckages
- Loading branch information
Showing
7 changed files
with
88 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.bcup | ||
*.DS_Store | ||
/coverage/ | ||
*.git-label-maker-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Ensures that the label package file actually exists | ||
* @param {String} path - path to the json file label package | ||
* @return {Bool || Error} this is a try-catch where the error | ||
*/ | ||
|
||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const isJsonString = require('../utils/is-json-string.js'); | ||
|
||
// Not using arrows bc it will mess up "this" context | ||
module.exports = function (jsonPath) { // eslint-disable-line func-names | ||
// Declare function as asynchronous, and save the done callback | ||
const done = this.async(); | ||
// this is clunky, but this way `we can just use a default | ||
if (jsonPath === '') done(true); | ||
try { | ||
if (jsonPath.indexOf('.json') < 0) { | ||
done('Not a JSON file'); | ||
return; | ||
} | ||
// Calculate the full path of the JSON file based upon the current working directory. Using | ||
// path.resolve allows for absolute paths to be used also. | ||
const fullPath = path.resolve(process.cwd(), jsonPath); | ||
fs.readFile(fullPath, (err, data) => { | ||
if (err) { done(err); return; } | ||
if (isJsonString(data)) { | ||
done(true); | ||
} | ||
done('Not a valid JSON file'); | ||
}); | ||
} catch (e) { | ||
done(e); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* The "Initial"/"Main" prompts | ||
*/ | ||
const menuChoices = require('../constants.js').menuChoices; | ||
|
||
module.exports = [ | ||
{ | ||
type: 'list', | ||
name: 'main', | ||
message: 'Welcome to git-labelmaker!\nWhat would you like to do?', | ||
choices: menuChoices, | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters