Skip to content

Commit ae39e1a

Browse files
committed
core: centralize the dev dir logic into node-gyp.js
1 parent 62e5851 commit ae39e1a

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

lib/configure.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ function configure (gyp, argv, callback) {
181181
function runGypAddon (err) {
182182
if (err) return callback(err)
183183

184-
var devDir = path.resolve(process.env.HOME, '.node-gyp', version)
185-
, gyp_addon = path.resolve(devDir, 'tools', 'gyp_addon')
184+
// location of the `gyp_addon` python script for the target node version
185+
var gyp_addon = path.resolve(gyp.devDir, version, 'tools', 'gyp_addon')
186186

187187
if (!~argv.indexOf('-f') && !~argv.indexOf('--format')) {
188188
if (win) {

lib/install.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ function install (gyp, argv, callback) {
6767
version = version.slice(1, 4).join('.')
6868
gyp.verbose('installing version', version)
6969

70-
71-
// TODO: Make ~/.node-gyp configurable
72-
var devDir = path.resolve(process.env.HOME, '.node-gyp', version)
70+
// the directory where the dev files will be installed
71+
var devDir = path.resolve(gyp.devDir, version)
7372

7473
// If '--ensure' was passed, then don't *always* install the version,
7574
// check if it is already installed, and only install when needed

lib/list.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ var fs = require('fs')
1212

1313
function list (gyp, args, callback) {
1414

15-
// TODO: Make ~/.node-gyp configurable
16-
var nodeGypDir = path.resolve(process.env.HOME, '.node-gyp')
17-
18-
gyp.verbose('using node-gyp dir', nodeGypDir)
15+
gyp.verbose('using node-gyp dir', gyp.devDir)
1916

2017
// readdir the node-gyp dir
21-
fs.readdir(nodeGypDir, onreaddir)
18+
fs.readdir(gyp.devDir, onreaddir)
2219

2320
function onreaddir (err, versions) {
2421
if (err && err.code != 'ENOENT') {

lib/node-gyp.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ function gyp () {
3838
function Gyp () {
3939
var me = this
4040

41+
// set the dir where node-gyp dev files get installed
42+
// TODO: make this configurable?
43+
// see: https://github.com/TooTallNate/node-gyp/issues/21
44+
var homeDir = process.env.HOME
45+
this.devDir = path.resolve(homeDir, '.node-gyp')
46+
4147
this.commands = {}
4248
commands.forEach(function (command) {
4349
me.commands[command] = function (argv, callback) {

lib/remove.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ var fs = require('fs')
1414

1515
function remove (gyp, argv, callback) {
1616

17-
// TODO: Make ~/.node-gyp configurable
18-
var nodeGypDir = path.resolve(process.env.HOME, '.node-gyp')
19-
20-
gyp.verbose('using node-gyp dir', nodeGypDir)
17+
gyp.verbose('using node-gyp dir', gyp.devDir)
2118

2219
// get the user-specified version to remove
2320
var v = argv[0] || gyp.opts.target
@@ -36,7 +33,7 @@ function remove (gyp, argv, callback) {
3633
// flatten the version Array into a String
3734
version = version.slice(1, 4).join('.')
3835

39-
var versionPath = path.resolve(nodeGypDir, version)
36+
var versionPath = path.resolve(gyp.devDir, version)
4037
gyp.verbose('removing development files for version', version)
4138

4239
// first check if its even installed

0 commit comments

Comments
 (0)