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

bin,lib: remove extra comments/lines/spaces #1508

Merged
merged 2 commits into from
Jul 28, 2018
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
10 changes: 1 addition & 9 deletions bin/node-gyp.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#!/usr/bin/env node

/**
* Set the title.
*/

process.title = 'node-gyp'

/**
* Module dependencies.
*/

var gyp = require('../')
var log = require('npmlog')
var osenv = require('osenv')
Expand Down Expand Up @@ -126,7 +118,7 @@ process.on('uncaughtException', function (err) {
})

function errorMessage () {
// copied from npm's lib/util/error-handler.js
Copy link
Member

@richardlau richardlau Jul 19, 2018

Choose a reason for hiding this comment

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

This is sort of an attribution (although the current path in npm now appears to be lib/utils/error-handler.js), so maybe keep?

// copied from npm's lib/utils/error-handler.js
var os = require('os')
log.error('System', os.type() + ' ' + os.release())
log.error('command', process.argv
Expand Down
14 changes: 1 addition & 13 deletions lib/build.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@

module.exports = exports = build

/**
* Module dependencies.
*/

var fs = require('graceful-fs')
, rm = require('rimraf')
, path = require('path')
Expand Down Expand Up @@ -32,8 +28,6 @@ function build (gyp, argv, callback) {
var release = processRelease(argv, gyp, process.version, process.release)
, makeCommand = gyp.opts.make || process.env.MAKE || platformMake
, command = win ? 'msbuild' : makeCommand
, buildDir = path.resolve('build')
, configPath = path.resolve(buildDir, 'config.gypi')
, jobs = gyp.opts.jobs || process.env.JOBS
, buildType
, config
Expand All @@ -47,6 +41,7 @@ function build (gyp, argv, callback) {
*/

function loadConfigGypi () {
var configPath = path.resolve('build', 'config.gypi')
fs.readFile(configPath, 'utf8', function (err, data) {
if (err) {
if (err.code == 'ENOENT') {
Expand Down Expand Up @@ -187,13 +182,11 @@ function build (gyp, argv, callback) {
})
}


/**
* Actually spawn the process and compile the module.
*/

function doBuild () {

// Enable Verbose build
var verbose = log.levels[log.level] <= log.levels.verbose
if (!win && verbose) {
Expand Down Expand Up @@ -253,10 +246,6 @@ function build (gyp, argv, callback) {
proc.on('exit', onExit)
}

/**
* Invoked after the make/msbuild command exits.
*/

function onExit (code, signal) {
if (code !== 0) {
return callback(new Error('`' + command + '` failed with exit code: ' + code))
Expand All @@ -266,5 +255,4 @@ function build (gyp, argv, callback) {
}
callback()
}

}
7 changes: 0 additions & 7 deletions lib/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@ module.exports = exports = clean

exports.usage = 'Removes any generated build files and the "out" dir'

/**
* Module dependencies.
*/

var rm = require('rimraf')
var log = require('npmlog')


function clean (gyp, argv, callback) {

// Remove the 'build' dir
var buildDir = 'build'

log.verbose('clean', 'removing "%s" directory', buildDir)
rm(buildDir, callback)

}
15 changes: 2 additions & 13 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ module.exports.test = {
findPython: findPython,
}

/**
* Module dependencies.
*/

var fs = require('graceful-fs')
, path = require('path')
, log = require('npmlog')
Expand All @@ -28,7 +24,6 @@ if (win)
exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module'

function configure (gyp, argv, callback) {

var python = gyp.opts.python || process.env.PYTHON || 'python2'
, buildDir = path.resolve('build')
, configNames = [ 'config.gypi', 'common.gypi' ]
Expand All @@ -46,7 +41,6 @@ function configure (gyp, argv, callback) {
})

function getNodeDir () {

// 'python' should be set by now
process.env.PYTHON = python

Expand All @@ -56,7 +50,6 @@ function configure (gyp, argv, callback) {

log.verbose('get node dir', 'compiling against specified --nodedir dev files: %s', nodeDir)
createBuildDir()

} else {
// if no --nodedir specified, ensure node dependencies are installed
if ('v' + release.version !== process.version) {
Expand Down Expand Up @@ -245,12 +238,12 @@ function configure (gyp, argv, callback) {
})

// For AIX and z/OS we need to set up the path to the exports file
// which contains the symbols needed for linking.
// which contains the symbols needed for linking.
var node_exp_file = undefined
if (process.platform === 'aix' || process.platform === 'os390') {
var ext = process.platform === 'aix' ? 'exp' : 'x'
var node_root_dir = findNodeDirectory()
var candidates = undefined
var candidates = undefined
if (process.platform === 'aix') {
candidates = ['include/node/node',
'out/Release/node',
Expand Down Expand Up @@ -336,10 +329,6 @@ function configure (gyp, argv, callback) {
})
}

/**
* Called when the `gyp` child process exits.
*/

function onCpExit (code, signal) {
if (code !== 0) {
callback(new Error('`gyp` failed with exit code: ' + code))
Expand Down
4 changes: 1 addition & 3 deletions lib/find-node-directory.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var path = require('path')
, log = require('npmlog')

function findNodeDirectory(scriptLocation, processObj) {
module.exports = function findNodeDirectory(scriptLocation, processObj) {
// set dirname and process if not passed in
// this facilitates regression tests
if (scriptLocation === undefined) {
Expand Down Expand Up @@ -57,5 +57,3 @@ function findNodeDirectory(scriptLocation, processObj) {
}
return node_root_dir
}

module.exports = findNodeDirectory
4 changes: 1 addition & 3 deletions lib/find-vs2017.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var log = require('npmlog')
, execFile = require('child_process').execFile
, path = require('path')

function findVS2017(callback) {
module.exports = function findVS2017(callback) {
var ps = path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell',
'v1.0', 'powershell.exe')
var csFile = path.join(__dirname, 'Find-VS2017.cs')
Expand Down Expand Up @@ -42,5 +42,3 @@ function findVS2017(callback) {

child.stdin.end()
}

module.exports = findVS2017
7 changes: 0 additions & 7 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ module.exports.test = {

exports.usage = 'Install node development files for the specified node version.'

/**
* Module dependencies.
*/

var fs = require('graceful-fs')
, osenv = require('osenv')
, tar = require('tar')
Expand All @@ -28,7 +24,6 @@ var fs = require('graceful-fs')
, win = process.platform == 'win32'

function install (fs, gyp, argv, callback) {

var release = processRelease(argv, gyp, process.version, process.release)

// ensure no double-callbacks happen
Expand Down Expand Up @@ -124,7 +119,6 @@ function install (fs, gyp, argv, callback) {
}

function go () {

log.verbose('ensuring nodedir is created', devDir)

// first create the dir for the node dev files
Expand Down Expand Up @@ -165,7 +159,6 @@ function install (fs, gyp, argv, callback) {
}

// download the tarball and extract!

if (tarPath) {
return tar.extract({
file: tarPath,
Expand Down
6 changes: 0 additions & 6 deletions lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ module.exports = exports = list

exports.usage = 'Prints a listing of the currently installed node development files'

/**
* Module dependencies.
*/

var fs = require('graceful-fs')
, path = require('path')
, log = require('npmlog')

function list (gyp, args, callback) {

var devDir = gyp.devDir
log.verbose('list', 'using node-gyp dir:', devDir)

// readdir() the node-gyp dir
fs.readdir(devDir, onreaddir)

function onreaddir (err, versions) {
Expand Down
13 changes: 0 additions & 13 deletions lib/node-gyp.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@

/**
* Module exports.
*/

module.exports = exports = gyp

/**
* Module dependencies.
*/

var fs = require('graceful-fs')
, path = require('path')
, nopt = require('nopt')
Expand All @@ -35,10 +27,6 @@ var fs = require('graceful-fs')
// differentiate node-gyp's logs from npm's
log.heading = 'gyp'

/**
* The `gyp` function.
*/

function gyp () {
return new Gyp()
}
Expand Down Expand Up @@ -213,4 +201,3 @@ Object.defineProperty(proto, 'version', {
}
, enumerable: true
})

43 changes: 15 additions & 28 deletions lib/process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var semver = require('semver')
, bitsreV3 = /\/win-(x86|ia32|x64)\// // io.js v3.x.x shipped with "ia32" but should
// have been "x86"

// Captures all the logic required to determine download URLs, local directory and
// Captures all the logic required to determine download URLs, local directory and
// file names. Inputs come from command-line switches (--target, --dist-url),
// `process.version` and `process.release` where it exists.
function processRelease (argv, gyp, defaultVersion, defaultRelease) {
Expand Down Expand Up @@ -88,35 +88,22 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) {
baseUrl = url.resolve(defaultRelease.headersUrl, './')
libUrl32 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x86', versionSemver.major)
libUrl64 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x64', versionSemver.major)

return {
version: version,
semver: versionSemver,
name: name,
baseUrl: baseUrl,
tarballUrl: defaultRelease.headersUrl,
shasumsUrl: url.resolve(baseUrl, 'SHASUMS256.txt'),
versionDir: (name !== 'node' ? name + '-' : '') + version,
libUrl32: libUrl32,
libUrl64: libUrl64,
libPath32: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)),
libPath64: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path))
}
tarballUrl = defaultRelease.headersUrl
} else {
// older versions without process.release are captured here and we have to make
// a lot of assumptions, additionally if you --target=x.y.z then we can't use the
// current process.release
baseUrl = distBaseUrl
libUrl32 = resolveLibUrl(name, baseUrl, 'x86', versionSemver.major)
libUrl64 = resolveLibUrl(name, baseUrl, 'x64', versionSemver.major)

// making the bold assumption that anything with a version number >3.0.0 will
// have a *-headers.tar.gz file in its dist location, even some frankenstein
// custom version
canGetHeaders = semver.satisfies(versionSemver, headersTarballRange)
tarballUrl = url.resolve(baseUrl, name + '-v' + version + (canGetHeaders ? '-headers' : '') + '.tar.gz')
}

// older versions without process.release are captured here and we have to make
// a lot of assumptions, additionally if you --target=x.y.z then we can't use the
// current process.release

baseUrl = distBaseUrl
libUrl32 = resolveLibUrl(name, baseUrl, 'x86', versionSemver.major)
libUrl64 = resolveLibUrl(name, baseUrl, 'x64', versionSemver.major)
// making the bold assumption that anything with a version number >3.0.0 will
// have a *-headers.tar.gz file in its dist location, even some frankenstein
// custom version
canGetHeaders = semver.satisfies(versionSemver, headersTarballRange)
tarballUrl = url.resolve(baseUrl, name + '-v' + version + (canGetHeaders ? '-headers' : '') + '.tar.gz')

return {
version: version,
semver: versionSemver,
Expand Down
1 change: 0 additions & 1 deletion lib/rebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports = exports = rebuild
exports.usage = 'Runs "clean", "configure" and "build" all at once'

function rebuild (gyp, argv, callback) {

gyp.todo.push(
{ name: 'clean', args: [] }
, { name: 'configure', args: argv }
Expand Down
6 changes: 0 additions & 6 deletions lib/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ module.exports = exports = remove

exports.usage = 'Removes the node development files for the specified version'

/**
* Module dependencies.
*/

var fs = require('fs')
, rm = require('rimraf')
, path = require('path')
, log = require('npmlog')
, semver = require('semver')

function remove (gyp, argv, callback) {

var devDir = gyp.devDir
log.verbose('remove', 'using node-gyp dir:', devDir)

Expand Down Expand Up @@ -48,5 +43,4 @@ function remove (gyp, argv, callback) {
// Go ahead and delete the dir
rm(versionPath, callback)
})

}