Skip to content

Commit

Permalink
feat(bin): Resolve custom config with process.cwd()
Browse files Browse the repository at this point in the history
So we do not have to pass the full path to the config (which is still possible)
  • Loading branch information
Kent C. Dodds committed Apr 27, 2016
1 parent 7a00d75 commit 1363040
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bin/p-s.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env node
/* eslint-disable */ // this file is not transpiled (maybe it should be?) so make sure it supports Node 0.10.0

var resolve = require('path').resolve
var findUp = require('find-up')
var isEmpty = require('lodash.isempty')
var merge = require('lodash.merge')
var remove = require('lodash.remove')
var contains = require('lodash.contains')
var shellEscape = require('shell-escape')
var program = require('commander')
var colors = require('colors/safe')

var runPackageScript = require('../dist').default
var binUtils = require('../dist/bin-utils')
Expand Down Expand Up @@ -41,8 +43,13 @@ runPackageScript({
})

function getPSConfig() {
var psConfigFilename = program.config || findUp.sync('package-scripts.js')
return require(psConfigFilename)
var psConfigFilename = program.config ? resolve(process.cwd(), program.config) : findUp.sync('package-scripts.js')
try {
return require(psConfigFilename)
} catch(e) {
console.warn(colors.yellow('Unable to find config at ' + psConfigFilename))
return {scripts: {}, options: {}}
}
}

function onHelp() {
Expand Down

0 comments on commit 1363040

Please sign in to comment.