Skip to content

Commit 93732a7

Browse files
committed
js: Convert the webdriver.promise namespace to a Closure module.
1 parent fb51ad7 commit 93732a7

File tree

10 files changed

+177
-206
lines changed

10 files changed

+177
-206
lines changed

Diff for: javascript/node/deploy.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ var optparse = require('./optparse');
2828

2929

3030
var CLOSURE_BASE_REGEX = /^var goog = goog \|\| \{\};/;
31-
var REQUIRE_REGEX = /^\s*(?:(?:var|let|const)\s+[a-zA-Z_$][a-zA-Z0-9$_]*\s*=\s*)?goog\.require\s*\(\s*[\'\"]([^\)]+)[\'\"]\s*\);?$/;
31+
var MODULE_REGEX = /^goog\.module\s*\(\s*[\'\"]([^\)]+)[\'\"]\s*\);?$/;
3232
var PROVIDE_REGEX = /^goog\.provide\s*\(\s*[\'\"]([^\)]+)[\'\"]\s*\);?$/;
33+
var REQUIRE_REGEX = /^\s*(?:(?:var|let|const)\s+[a-zA-Z_$][a-zA-Z0-9$_]*\s*=\s*)?goog\.require\s*\(\s*[\'\"]([^\)]+)[\'\"]\s*\);?$/;
3334

3435

3536
/**
3637
* Map of file paths to a hash of what symbols that file provides and requires.
37-
* @type {!Object.<{provides: !Array.<string>,
38+
* @type {!Object.<{modules: boolean,
39+
* provides: !Array.<string>,
3840
* requires: !Array.<string>}>}
3941
*/
4042
var FILE_INFO = {};
@@ -104,14 +106,18 @@ function updateProviders(path, symbol) {
104106
*/
105107
function parseFile(path) {
106108
var contents = fs.readFileSync(path, 'utf8');
107-
var info = {provides: [], requires: []};
109+
var info = {module: false, provides: [], requires: []};
108110
FILE_INFO[path] = info;
109111

110112
contents.split(/\n/).forEach(function(line) {
111113
var match = line.match(REQUIRE_REGEX);
112114
if (match) {
113115
info.requires.push(match[1]);
114116
addRequiredEdge(path, match[1]);
117+
} else if (match = line.match(MODULE_REGEX)) {
118+
info.module = true;
119+
info.provides.push(match[1]);
120+
updateProviders(path, match[1]);
115121
} else if (match = line.match(PROVIDE_REGEX)) {
116122
info.provides.push(match[1]);
117123
updateProviders(path, match[1]);
@@ -244,7 +250,8 @@ function copyLibraries(outputDirPath, filePaths) {
244250
'goog.addDependency(',
245251
JSON.stringify(relativePath), ', ',
246252
JSON.stringify(FILE_INFO[file].provides), ', ',
247-
JSON.stringify(FILE_INFO[file].requires),
253+
JSON.stringify(FILE_INFO[file].requires), ', ',
254+
!!FILE_INFO[file].module,
248255
');'
249256
].join(''));
250257

Diff for: javascript/safari-driver/inject/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ goog.provide('safaridriver.inject.util');
2121

2222
goog.require('bot.response');
2323
goog.require('safaridriver.message.LoadModule');
24-
goog.require('webdriver.promise.Promise');
24+
goog.require('webdriver.promise');
2525

2626

2727
/**

Diff for: javascript/webdriver/http/http.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ goog.require('goog.array');
2727
goog.require('goog.json');
2828
goog.require('webdriver.CommandExecutor');
2929
goog.require('webdriver.CommandName');
30-
goog.require('webdriver.promise.Deferred');
30+
goog.require('webdriver.promise');
3131

3232

3333

0 commit comments

Comments
 (0)