diff --git a/.travis.yml b/.travis.yml index 60d88692..1b27b3f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ node_js: - '8' - '6' - '4' + - '4.4.7' + - '4.2.3' before_script: - echo -e "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config script: diff --git a/appveyor.yml b/appveyor.yml index eeda657b..ce69c49e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,6 +12,7 @@ install: # Get the latest stable version of Node.js or io.js - ps: Install-Product node $env:nodejs_version # install modules + - npm cache clean --force - npm i --no-cache # Post-install test scripts. diff --git a/lib/patch_buffer.js b/lib/patch_buffer.js new file mode 100644 index 00000000..365477ec --- /dev/null +++ b/lib/patch_buffer.js @@ -0,0 +1,12 @@ +'use strict'; + +// make sure buffer.alloc exists on 4.2.3 <= Node.js < 4.5.0 +// it use on tar@^4.0.0 + +if (typeof Buffer.alloc === 'undefined') { + Buffer.alloc = function alloc(size, fill, encoding) { + const buf = new Buffer(size); + buf.fill(fill, encoding); + return buf; + }; +} diff --git a/lib/utils.js b/lib/utils.js index 5a566791..e2da9bcb 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -4,7 +4,10 @@ const debug = require('debug')('npminstall:utils'); const fs = require('mz/fs'); const path = require('path'); const cp = require('child_process'); + +require('./patch_buffer'); const tar = require('tar'); + const zlib = require('zlib'); const _rimraf = require('rimraf'); const _mkdirp = require('mkdirp');