Skip to content

Commit 8a83972

Browse files
Siilwynrvagg
authored andcommitted
bin: follow XDG OS conventions for storing data
PR-URL: #1570 Fixes: #175 Fixes: #1124 Reviewed-By: Refael Ackermann <[email protected]>
1 parent 8098ebd commit 8a83972

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Some additional resources for addons and writing `gyp` files:
170170
| `--thin=yes` | Enable thin static libraries
171171
| `--arch=$arch` | Set target architecture (e.g. ia32)
172172
| `--tarball=$path` | Get headers from a local tarball
173-
| `--devdir=$path` | SDK download directory (default is `~/.node-gyp`)
173+
| `--devdir=$path` | SDK download directory (default is OS cache directory)
174174
| `--ensure` | Don't reinstall headers if already present
175175
| `--dist-url=$url` | Download header tarball from custom URL
176176
| `--proxy=$url` | Set HTTP proxy for downloading header tarball

bin/node-gyp.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
process.title = 'node-gyp'
44

5+
var envPaths = require('env-paths')
56
var gyp = require('../')
67
var log = require('npmlog')
78
var os = require('os')
8-
var path = require('path')
99

1010
/**
1111
* Process and execute the selected commands.
@@ -20,7 +20,7 @@ var homeDir = os.homedir()
2020
if (prog.devDir) {
2121
prog.devDir = prog.devDir.replace(/^~/, homeDir)
2222
} else if (homeDir) {
23-
prog.devDir = path.resolve(homeDir, '.node-gyp')
23+
prog.devDir = envPaths('node-gyp', { suffix: '' }).cache
2424
} else {
2525
throw new Error(
2626
"node-gyp requires that the user's home directory is specified " +

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"bin": "./bin/node-gyp.js",
2323
"main": "./lib/node-gyp.js",
2424
"dependencies": {
25+
"env-paths": "^1.0.0",
2526
"glob": "^7.0.3",
2627
"graceful-fs": "^4.1.2",
2728
"mkdirp": "^0.5.0",

0 commit comments

Comments
 (0)