Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creating plans in custom directory #93

Merged
merged 2 commits into from
Oct 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions microplan-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ async.waterfall([
function _parseInputFromUser (callback) {
program
.option('-t, --template <location>', 'specify input template location', templateFileLocation.yaml)
.option('-d, --directory <location>', 'specify plan output directory')
.parse(process.argv)

if (program.args.length < 1) {
callback('Please specify a valid filename for plan output.', null)
}

var destFilePath = program.args[0]

if (utils.fileExists(program.template) === false) {
Expand All @@ -51,9 +51,16 @@ function _parseInputFromUser (callback) {

if (suppFileExtns.indexOf(fileExt) === -1) {
callback('Template extension not supported. Please use supported file extensions: ' + suppFileExtns.join(', '), null)
} else {
callback(null, program.template, destFilePath)
}

if (program.directory) {
if (utils.directoryExists(program.directory) === false) {
callback('Please provide a valid directory path', null)
}
destFilePath = path.join(program.directory, destFilePath)
}

callback(null, program.template, destFilePath)
}

function _getOptsFromUser (templateFilePath, destFilePath, callback) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microplan",
"version": "1.4.2",
"version": "1.5.0",
Copy link
Collaborator

@argonlaser argonlaser Oct 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a recently merged change which breaks the module. So, we should bump the major version.
Also, not sure if this is the right time to publish as few tasks are still pending.
Lets hear @scriptnull inputs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine. We recently removed autopublish to npm. I will merge this PR with this change. We will increment the major version after pushing few more changes and go for release. Until that, let the version be this.

"description": "Plan your project from command line",
"main": "microplan.js",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,17 @@ function fileExists (filePath) {
}
}

function directoryExists (dirPath) {
try {
return fs.statSync(dirPath).isDirectory()
} catch (err) {
return false
}
}

module.exports =
{
fileExists: fileExists,
directoryExists: directoryExists,
parseSlug: parseSlug
}