Skip to content

Commit

Permalink
core: centralize the dev dir logic into node-gyp.js
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Mar 31, 2012
1 parent 62e5851 commit ae39e1a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ function configure (gyp, argv, callback) {
function runGypAddon (err) {
if (err) return callback(err)

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

if (!~argv.indexOf('-f') && !~argv.indexOf('--format')) {
if (win) {
Expand Down
5 changes: 2 additions & 3 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ function install (gyp, argv, callback) {
version = version.slice(1, 4).join('.')
gyp.verbose('installing version', version)


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

// If '--ensure' was passed, then don't *always* install the version,
// check if it is already installed, and only install when needed
Expand Down
7 changes: 2 additions & 5 deletions lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ var fs = require('fs')

function list (gyp, args, callback) {

// TODO: Make ~/.node-gyp configurable
var nodeGypDir = path.resolve(process.env.HOME, '.node-gyp')

gyp.verbose('using node-gyp dir', nodeGypDir)
gyp.verbose('using node-gyp dir', gyp.devDir)

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

function onreaddir (err, versions) {
if (err && err.code != 'ENOENT') {
Expand Down
6 changes: 6 additions & 0 deletions lib/node-gyp.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ function gyp () {
function Gyp () {
var me = this

// set the dir where node-gyp dev files get installed
// TODO: make this configurable?
// see: https://github.com/TooTallNate/node-gyp/issues/21
var homeDir = process.env.HOME
this.devDir = path.resolve(homeDir, '.node-gyp')

this.commands = {}
commands.forEach(function (command) {
me.commands[command] = function (argv, callback) {
Expand Down
7 changes: 2 additions & 5 deletions lib/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ var fs = require('fs')

function remove (gyp, argv, callback) {

// TODO: Make ~/.node-gyp configurable
var nodeGypDir = path.resolve(process.env.HOME, '.node-gyp')

gyp.verbose('using node-gyp dir', nodeGypDir)
gyp.verbose('using node-gyp dir', gyp.devDir)

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

var versionPath = path.resolve(nodeGypDir, version)
var versionPath = path.resolve(gyp.devDir, version)
gyp.verbose('removing development files for version', version)

// first check if its even installed
Expand Down

0 comments on commit ae39e1a

Please sign in to comment.