Skip to content

Commit a069253

Browse files
author
Lars-Magnus Skog
committed
remove .nolocal 🔥 (remnant from prebuild)
1 parent d90cfac commit a069253

File tree

4 files changed

+38
-62
lines changed

4 files changed

+38
-62
lines changed

download.js

Lines changed: 38 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,75 +15,58 @@ var mkdirp = require('mkdirp')
1515

1616
function downloadPrebuild (downloadUrl, opts, cb) {
1717
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
18-
var localPrebuild = util.localPrebuild(downloadUrl)
1918
var tempFile = util.tempFile(cachedPrebuild)
20-
2119
var log = opts.log || noop
2220

23-
if (opts.nolocal) return download()
24-
25-
log.info('looking for local prebuild @', localPrebuild)
26-
fs.access(localPrebuild, fs.R_OK | fs.W_OK, function (err) {
27-
if (err && err.code === 'ENOENT') {
28-
return download()
29-
}
30-
31-
log.info('found local prebuild')
32-
cachedPrebuild = localPrebuild
33-
unpack()
34-
})
35-
36-
function download () {
37-
ensureNpmCacheDir(function (err) {
38-
if (err) return onerror(err)
21+
ensureNpmCacheDir(function (err) {
22+
if (err) return onerror(err)
3923

40-
log.info('looking for cached prebuild @', cachedPrebuild)
41-
fs.access(cachedPrebuild, fs.R_OK | fs.W_OK, function (err) {
42-
if (!(err && err.code === 'ENOENT')) {
43-
log.info('found cached prebuild')
44-
return unpack()
45-
}
24+
log.info('looking for cached prebuild @', cachedPrebuild)
25+
fs.access(cachedPrebuild, fs.R_OK | fs.W_OK, function (err) {
26+
if (!(err && err.code === 'ENOENT')) {
27+
log.info('found cached prebuild')
28+
return unpack()
29+
}
4630

47-
log.http('request', 'GET ' + downloadUrl)
48-
var reqOpts = proxy({ url: downloadUrl }, opts)
31+
log.http('request', 'GET ' + downloadUrl)
32+
var reqOpts = proxy({ url: downloadUrl }, opts)
4933

50-
if (opts.token) {
51-
reqOpts.url += '?access_token=' + opts.token
52-
reqOpts.headers = {
53-
'User-Agent': 'simple-get',
54-
'Accept': 'application/octet-stream'
55-
}
34+
if (opts.token) {
35+
reqOpts.url += '?access_token=' + opts.token
36+
reqOpts.headers = {
37+
'User-Agent': 'simple-get',
38+
'Accept': 'application/octet-stream'
5639
}
40+
}
5741

58-
var req = get(reqOpts, function (err, res) {
59-
if (err) return onerror(err)
60-
log.http(res.statusCode, downloadUrl)
61-
if (res.statusCode !== 200) return onerror()
62-
mkdirp(util.prebuildCache(), function () {
63-
log.info('downloading to @', tempFile)
64-
pump(res, fs.createWriteStream(tempFile), function (err) {
65-
if (err) return onerror(err)
66-
fs.rename(tempFile, cachedPrebuild, function (err) {
67-
if (err) return cb(err)
68-
log.info('renaming to @', cachedPrebuild)
69-
unpack()
70-
})
42+
var req = get(reqOpts, function (err, res) {
43+
if (err) return onerror(err)
44+
log.http(res.statusCode, downloadUrl)
45+
if (res.statusCode !== 200) return onerror()
46+
mkdirp(util.prebuildCache(), function () {
47+
log.info('downloading to @', tempFile)
48+
pump(res, fs.createWriteStream(tempFile), function (err) {
49+
if (err) return onerror(err)
50+
fs.rename(tempFile, cachedPrebuild, function (err) {
51+
if (err) return cb(err)
52+
log.info('renaming to @', cachedPrebuild)
53+
unpack()
7154
})
7255
})
7356
})
74-
75-
req.setTimeout(30 * 1000, function () {
76-
req.abort()
77-
})
7857
})
7958

80-
function onerror (err) {
81-
fs.unlink(tempFile, function () {
82-
cb(err || error.noPrebuilts(opts))
83-
})
84-
}
59+
req.setTimeout(30 * 1000, function () {
60+
req.abort()
61+
})
8562
})
86-
}
63+
64+
function onerror (err) {
65+
fs.unlink(tempFile, function () {
66+
cb(err || error.noPrebuilts(opts))
67+
})
68+
}
69+
})
8770

8871
function unpack () {
8972
var binaryName

test/asset-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ test('non existing version should fail asset request', function (t) {
124124
function getOpts () {
125125
return {
126126
pkg: require('a-native-module/package'),
127-
nolocal: true,
128127
runtime: 'node',
129128
platform: process.platform,
130129
arch: process.arch,

test/download-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ test('should fail if abi is system abi with invalid binary', function (t) {
220220
function getOpts () {
221221
return {
222222
pkg: require('a-native-module/package'),
223-
nolocal: true,
224223
runtime: 'node',
225224
platform: process.platform,
226225
arch: process.arch,

util.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,11 @@ function tempFile (cached) {
8686
return cached + '.' + process.pid + '-' + Math.random().toString(16).slice(2) + '.tmp'
8787
}
8888

89-
function localPrebuild (url) {
90-
return path.join('prebuilds', path.basename(url))
91-
}
92-
9389
exports.getDownloadUrl = getDownloadUrl
9490
exports.getApiUrl = getApiUrl
9591
exports.getAssetUrl = getAssetUrl
9692
exports.urlTemplate = urlTemplate
9793
exports.cachedPrebuild = cachedPrebuild
98-
exports.localPrebuild = localPrebuild
9994
exports.prebuildCache = prebuildCache
10095
exports.npmCache = npmCache
10196
exports.tempFile = tempFile

0 commit comments

Comments
 (0)