Skip to content

Commit

Permalink
Don't use reserved word package for variable
Browse files Browse the repository at this point in the history
It causes conflict for some linters and builders.

Credit: @adius
PR-URL: #62
  • Loading branch information
ad-si authored and zkat committed May 18, 2016
1 parent 12eb24f commit 2e1adaa
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions init-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function init (dir, input, config, cb) {
}
}

var package = path.resolve(dir, 'package.json')
var packageFile = path.resolve(dir, 'package.json')
input = path.resolve(input)
var pkg
var ctx = { yes: yes(config) }
Expand All @@ -49,14 +49,14 @@ function init (dir, input, config, cb) {
readJson.extraSet = es.filter(function (fn) {
return fn.name !== 'authors' && fn.name !== 'mans'
})
readJson(package, function (er, d) {
readJson(packageFile, function (er, d) {
readJson.extraSet = es

if (er) pkg = {}
else pkg = d

ctx.filename = package
ctx.dirname = path.dirname(package)
ctx.filename = packageFile
ctx.dirname = path.dirname(packageFile)
ctx.basename = path.basename(ctx.dirname)
if (!pkg.version || !semver.valid(pkg.version))
delete pkg.version
Expand All @@ -80,7 +80,7 @@ function init (dir, input, config, cb) {
readJson.extraSet = es.filter(function (fn) {
return fn.name !== 'authors' && fn.name !== 'mans'
})
readJson.extras(package, pkg, function (er, pkg) {
readJson.extras(packageFile, pkg, function (er, pkg) {
readJson.extraSet = es
if (er) return cb(er, pkg)
pkg = unParsePeople(pkg)
Expand All @@ -105,17 +105,17 @@ function init (dir, input, config, cb) {

var d = JSON.stringify(pkg, null, 2) + '\n'
function write (yes) {
fs.writeFile(package, d, 'utf8', function (er) {
fs.writeFile(packageFile, d, 'utf8', function (er) {
if (!er && yes && !config.get('silent')) {
console.log('Wrote to %s:\n\n%s\n', package, d)
console.log('Wrote to %s:\n\n%s\n', packageFile, d)
}
return cb(er, pkg)
})
}
if (ctx.yes) {
return write(true)
}
console.log('About to write to %s:\n\n%s\n', package, d)
console.log('About to write to %s:\n\n%s\n', packageFile, d)
read({prompt:'Is this ok? ', default: 'yes'}, function (er, ok) {
if (!ok || ok.toLowerCase().charAt(0) !== 'y') {
console.log('Aborted.')
Expand Down

0 comments on commit 2e1adaa

Please sign in to comment.