From 2b5ce52a26018692e89377b0504e7efa3b4900b6 Mon Sep 17 00:00:00 2001 From: Selwyn Date: Sat, 13 Oct 2018 15:12:15 +0200 Subject: [PATCH] bin: follow XDG OS conventions for storing data PR-URL: https://github.com/nodejs/node-gyp/pull/1570 Fixes: https://github.com/nodejs/node-gyp/pull/175 Fixes: https://github.com/nodejs/node-gyp/pull/1124 Reviewed-By: Refael Ackermann --- README.md | 2 +- bin/node-gyp.js | 4 ++-- package.json | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e88bd0b5be..f378616964 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ Some additional resources for addons and writing `gyp` files: | `--thin=yes` | Enable thin static libraries | `--arch=$arch` | Set target architecture (e.g. ia32) | `--tarball=$path` | Get headers from a local tarball -| `--devdir=$path` | SDK download directory (default is `~/.node-gyp`) +| `--devdir=$path` | SDK download directory (default is OS cache directory) | `--ensure` | Don't reinstall headers if already present | `--dist-url=$url` | Download header tarball from custom URL | `--proxy=$url` | Set HTTP proxy for downloading header tarball diff --git a/bin/node-gyp.js b/bin/node-gyp.js index 9978c3b35f..8c9b6169bb 100755 --- a/bin/node-gyp.js +++ b/bin/node-gyp.js @@ -2,10 +2,10 @@ process.title = 'node-gyp' +var envPaths = require('env-paths') var gyp = require('../') var log = require('npmlog') var os = require('os') -var path = require('path') /** * Process and execute the selected commands. @@ -20,7 +20,7 @@ var homeDir = os.homedir() if (prog.devDir) { prog.devDir = prog.devDir.replace(/^~/, homeDir) } else if (homeDir) { - prog.devDir = path.resolve(homeDir, '.node-gyp') + prog.devDir = envPaths('node-gyp', { suffix: '' }).cache } else { throw new Error( "node-gyp requires that the user's home directory is specified " + diff --git a/package.json b/package.json index 10dab6418e..883a774086 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "bin": "./bin/node-gyp.js", "main": "./lib/node-gyp.js", "dependencies": { + "env-paths": "^1.0.0", "glob": "^7.0.3", "graceful-fs": "^4.1.2", "mkdirp": "^0.5.0",