From 284389a4cc57cabeb1d3bd5d5498bc5e3c74ca6f Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Tue, 30 Jun 2015 15:32:40 -0700 Subject: [PATCH] fix node test downloader --- bin/download-node-tests.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/download-node-tests.js b/bin/download-node-tests.js index 0f15dbb..9b7a4d6 100755 --- a/bin/download-node-tests.js +++ b/bin/download-node-tests.js @@ -6,7 +6,7 @@ var split = require('split') var thru = require('through2') var fs = require('fs') -var url = 'https://api.github.com/repos/iojs/io.js/contents' +var url = 'https://api.github.com/repos/nodejs/io.js/contents' var dirs = [ '/test/parallel', '/test/pummel' @@ -41,9 +41,7 @@ function downloadBufferTests (dir, files) { path = __dirname + '/../test/es6/' + file.name } - var downloadUrl = file.download_url.replace('/master/', '/v1.x/') - - hyperquest(downloadUrl, httpOpts) + hyperquest(file.download_url, httpOpts) .pipe(split()) .pipe(testfixer(file.name)) .pipe(fs.createWriteStream(path)) @@ -58,18 +56,22 @@ function testfixer (filename) { if (firstline) { // require buffer explicitly - line = 'var Buffer = require(\'../../\').Buffer\n' + - 'if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false\n' + - line + var preamble = 'var Buffer = require(\'../../\').Buffer;\n' + + 'if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false;' + if (/use strict/.test(line)) line += '\n' + preamble + else line + preamble + '\n' + line firstline = false } // comment out require('common') - line = line.replace(/(var common = require.*)/, 'var common = {};') + line = line.replace(/((var|const) common = require.*)/, 'var common = {};') // require browser buffer line = line.replace(/(.*)require\('buffer'\)(.*)/, '$1require(\'../../\')$2') + // de-const Buffer (in case it's required explicitly with a const by a node test) + line = line.replace(/const Buffer/, 'var Buffer') + // smalloc is only used for kMaxLength line = line.replace(/require\('smalloc'\)/, '{ kMaxLength: 0x3FFFFFFF }') -- 2.34.1