Skip to content

Commit

Permalink
Merge pull request #112 from joshuatvernon/print-simple-script-bugfix
Browse files Browse the repository at this point in the history
Print simple script bugfix
  • Loading branch information
joshuatvernon authored Nov 5, 2020
2 parents addb675 + 70fcb48 commit a7a2118
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cbf",
"version": "2.3.1",
"version": "2.3.2",
"description": "A package for creating scripts to store and run your most commonly used CLI commands for a repo or just in general",
"main": "index.js",
"scripts": {
Expand Down
52 changes: 34 additions & 18 deletions src/program/operations/print/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,40 @@ const OPERATION_DESCRIPTION = 'print a saved script';
* @param {string} scriptName - the name of the script to be printed
*/
const printScript = scriptName => {
fse
.readFile(`${SCRIPTS_DIRECTORY_PATH}/${scriptName}.yml`)
.then(yamlFile => {
printMessage(
formatMessage(messages.printScript, {
scriptName,
script: yamlFile,
}),
);
})
.catch(error => {
printMessage(
formatMessage(messages.errorPrintingScript, {
scriptName,
error,
}),
);
});
let scriptPath = '';
if (fse.existsSync(`${SCRIPTS_DIRECTORY_PATH}/${scriptName}.yml`)) {
// Print script
scriptPath = `${SCRIPTS_DIRECTORY_PATH}/${scriptName}.yml`;
} else if (fse.existsSync(`${SCRIPTS_DIRECTORY_PATH}/${scriptName}.simple.yml`)) {
// Print simple script
scriptPath = `${SCRIPTS_DIRECTORY_PATH}/${scriptName}.simple.yml`;
}
if (scriptPath) {
fse
.readFile(scriptPath)
.then(script => {
printMessage(
formatMessage(messages.printScript, {
script,
scriptName,
}),
);
})
.catch(error => {
printMessage(
formatMessage(messages.errorPrintingScript, {
error,
scriptName,
}),
);
});
} else {
printMessage(
formatMessage(globalMessages.scriptDoesNotExist, {
scriptName,
}),
);
}
};

/**
Expand Down
2 changes: 1 addition & 1 deletion version.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// generated by genversion
module.exports = '2.3.1';
module.exports = '2.3.2';

0 comments on commit a7a2118

Please sign in to comment.