Skip to content

Commit accc94c

Browse files
authored
Merge pull request webpack#4679 from timse/rename-async-for-future-compatibility
Rename async for future compatibility
2 parents 84c639e + db0dbc3 commit accc94c

4 files changed

Lines changed: 33 additions & 29 deletions

File tree

benchmark/createFixtures2.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ try {
99

1010
function genModule(prefix, depth, asyncDepth, multiplex, r, circular) {
1111
var source = [];
12-
var async = depth >= asyncDepth;
13-
if(!async)
12+
var isAsync = depth >= asyncDepth;
13+
if(!isAsync)
1414
circular.push(path.resolve(fixtures, prefix + "/index.js"));
1515
source.push("(function() {");
1616
var m = (r % multiplex) + 1;
@@ -23,7 +23,7 @@ function genModule(prefix, depth, asyncDepth, multiplex, r, circular) {
2323
sum += genModule(prefix + "/" + i, depth - 1, asyncDepth, multiplex, (r + i + depth) * m + i + depth, circular);
2424
source.push("require(" + JSON.stringify("./" + i) + ");");
2525
if(i === 0) {
26-
if(async)
26+
if(isAsync)
2727
source.push("}); require.ensure([], function() {");
2828
}
2929
}
@@ -42,8 +42,8 @@ for(var i = 2; i < 14; i++) {
4242
console.log("generated tree", i, count);
4343
}
4444

45-
for(var i = 2; i < 14; i++) {
46-
var count = genModule("async-tree-" + i, 6, 1, i, 0, []);
45+
for(i = 2; i < 14; i++) {
46+
count = genModule("async-tree-" + i, 6, 1, i, 0, []);
4747
console.log("generated async tree", i, count);
4848
}
4949

test/BinTestCases.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
/* globals describe it before */
12
"use strict";
23

3-
/* globals describe it */
44
const should = require("should");
55
const path = require("path");
66
const fs = require("fs");
@@ -9,12 +9,12 @@ const spawn = require("child_process").spawn;
99
function loadOptsFile(optsPath) {
1010
// Options file parser from Mocha
1111
// https://github.com/mochajs/mocha/blob/2bb2b9fa35818db7a02e5068364b0c417436b1af/bin/options.js#L25-L31
12-
return fs.readFileSync(optsPath, 'utf8')
13-
.replace(/\\\s/g, '%20')
12+
return fs.readFileSync(optsPath, "utf8")
13+
.replace(/\\\s/g, "%20")
1414
.split(/\s/)
1515
.filter(Boolean)
1616
.map(function(value) {
17-
return value.replace(/%20/g, ' ');
17+
return value.replace(/%20/g, " ");
1818
});
1919
}
2020

@@ -28,15 +28,15 @@ function getTestSpecificArguments(testDirectory) {
2828

2929
function convertToArrayOfLines(outputArray) {
3030
if(outputArray.length === 0) return outputArray;
31-
return outputArray.join('').split('\n');
31+
return outputArray.join("").split("\n");
3232
}
3333

3434
const casesPath = path.join(__dirname, "binCases");
3535
const defaultArgs = loadOptsFile(path.join(casesPath, "test.opts"));
3636

3737
describe("BinTestCases", function() {
3838
const categoryDirectories = fs.readdirSync(casesPath).filter((folder) => {
39-
return fs.statSync(path.join(casesPath, folder)).isDirectory()
39+
return fs.statSync(path.join(casesPath, folder)).isDirectory();
4040
});
4141

4242
const categories = categoryDirectories.map(function(categoryDirectory) {
@@ -61,15 +61,15 @@ describe("BinTestCases", function() {
6161
cwd: path.resolve("./", testDirectory)
6262
};
6363

64-
const async = fs.existsSync(path.join(testDirectory, "async"));
64+
const asyncExists = fs.existsSync(path.join(testDirectory, "async"));
6565

6666
const env = {
6767
stdout: [],
6868
stderr: [],
6969
error: []
7070
};
7171

72-
if(async) {
72+
if(asyncExists) {
7373
describe(testName, function() {
7474
it("should run successfully", function(done) {
7575
this.timeout(10000);
@@ -93,16 +93,16 @@ describe("BinTestCases", function() {
9393

9494
setTimeout(() => {
9595
if(env.code) {
96-
done(`Watch didn't run ${env.error}`)
96+
done(`Watch didn't run ${env.error}`);
9797
}
9898

9999
const stdout = convertToArrayOfLines(env.stdout);
100100
const stderr = convertToArrayOfLines(env.stderr);
101101
testAssertions(stdout, stderr, done);
102-
child.kill()
102+
child.kill();
103103
}, 3000); // wait a little to get an output
104104
});
105-
})
105+
});
106106
} else {
107107
describe(testName, function() {
108108
before(function(done) {

test/cases/chunks/runtime/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* globals it */
12
it("should handle duplicate chunks", function(done) {
23
var firstOne = false, secondOne = false;
34
require.ensure([], function(require) {
@@ -17,23 +18,27 @@ it("should handle duplicate chunks", function(done) {
1718
});
1819

1920
it("should not load a chunk which is included in a already loaded one", function(done) {
20-
var async = false;
21+
var asyncFlag = false;
2122
require.ensure(["./empty?x", "./empty?y", "./empty?z"], function(require) {
2223
try {
23-
async.should.be.eql(true);
24+
asyncFlag.should.be.eql(true);
2425
loadChunk();
25-
} catch(e) { done(e); }
26+
} catch(e) {
27+
done(e);
28+
}
2629
});
2730
Promise.resolve().then(function() {}).then(function() {}).then(function() {
28-
async = true;
31+
asyncFlag = true;
2932
});
3033
function loadChunk() {
3134
var sync = true;
3235
require.ensure(["./empty?x", "./empty?y"], function(require) {
3336
try {
3437
sync.should.be.eql(true);
3538
done();
36-
} catch(e) { done(e); }
39+
} catch(e) {
40+
done(e);
41+
}
3742
});
3843
Promise.resolve().then(function() {}).then(function() {}).then(function() {
3944
sync = false;
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
var path = require('path');
2-
var async = require('async');
1+
var asyncLib = require("async");
32
module.exports = function(content) {
43
var cb = this.async();
54
var json = JSON.parse(content);
6-
async.mapSeries(
5+
asyncLib.mapSeries(
76
json.imports,
87
function(url, callback) {
98
this.loadModule(url, function(err, source, map, module) {
10-
if (err) {
9+
if(err) {
1110
return callback(err);
1211
}
1312
callback(null, this.exec(source, url));
14-
}.bind(this))
13+
}.bind(this));
1514
}.bind(this),
1615
function(err, results) {
17-
if (err) {
16+
if(err) {
1817
return cb(err);
1918
}
2019
// Combine all the results into one object and return it
21-
cb(null, 'module.exports = ' + JSON.stringify(results.reduce(function(prev, result) {
20+
cb(null, "module.exports = " + JSON.stringify(results.reduce(function(prev, result) {
2221
return Object.assign({}, prev, result);
2322
}, json)));
2423
}
2524
);
26-
}
25+
};

0 commit comments

Comments
 (0)