Skip to content

Don't use reserved word "package" for variable #62

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

Closed
wants to merge 1 commit into from
Closed
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
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