Update node-haste from upstream

Reviewed By: zpao

Differential Revision: D2747183

fb-gh-sync-id: f1b963b19cb6ea16945b16370d1bee26110bb329
This commit is contained in:
Christoph Pojer 2015-12-10 17:58:30 -08:00 committed by facebook-github-bot-3
parent f1e32aee6f
commit a04e2bed54
4 changed files with 39 additions and 54 deletions

View File

@ -1362,19 +1362,19 @@ describe('DependencyGraph', function() {
});
});
testBrowserField('browser')
testBrowserField('react-native')
testBrowserField('browser');
testBrowserField('react-native');
function replaceBrowserField (json, fieldName) {
function replaceBrowserField(json, fieldName) {
if (fieldName !== 'browser') {
json[fieldName] = json.browser
delete json.browser
json[fieldName] = json.browser;
delete json.browser;
}
return json
return json;
}
function testBrowserField (fieldName) {
function testBrowserField(fieldName) {
pit('should support simple browser field in packages ("' + fieldName + '")', function() {
var root = '/root';
fs.__setMockFilesystem({
@ -1393,8 +1393,8 @@ describe('DependencyGraph', function() {
}, fieldName)),
'main.js': 'some other code',
'client.js': 'some code',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1448,8 +1448,8 @@ describe('DependencyGraph', function() {
}, fieldName)),
'main.js': 'some other code',
'client.js': 'some code',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1503,8 +1503,8 @@ describe('DependencyGraph', function() {
}, fieldName)),
'main.js': 'some other code',
'client.js': 'some code',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1559,8 +1559,8 @@ describe('DependencyGraph', function() {
}, fieldName)),
'main.js': 'some other code',
'client.js': 'some code',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1630,15 +1630,15 @@ describe('DependencyGraph', function() {
},
'hello.js': 'hello',
'bye.js': 'bye',
}
}
},
},
});
var dgraph = new DependencyGraph({
...defaults,
roots: [root],
});
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
const dgraph = new DependencyGraph({
...defaults,
roots: [root],
});
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
expect(deps)
.toEqual([
{ id: 'index',
@ -1716,7 +1716,7 @@ describe('DependencyGraph', function() {
name: 'aPackage',
browser: {
'node-package': 'browser-package',
}
},
}, fieldName)),
'index.js': 'require("node-package")',
'node-package': {
@ -1731,8 +1731,8 @@ describe('DependencyGraph', function() {
}),
'index.js': 'some browser code',
},
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1788,7 +1788,7 @@ describe('DependencyGraph', function() {
name: 'aPackage',
browser: {
'node-package': 'browser-package',
}
},
}, fieldName)),
'index.js': 'require("node-package")',
'node-package': {
@ -1803,8 +1803,8 @@ describe('DependencyGraph', function() {
}),
'index.js': 'some browser code',
},
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1861,13 +1861,13 @@ describe('DependencyGraph', function() {
name: 'aPackage',
'react-native': {
'node-package': 'rn-package',
}
},
}),
'index.js': 'require("node-package")',
'node_modules': {
'node-package': {
'package.json': JSON.stringify({
'name': 'node-package'
'name': 'node-package',
}),
'index.js': 'some node code',
},
@ -1875,8 +1875,8 @@ describe('DependencyGraph', function() {
'package.json': JSON.stringify({
'name': 'rn-package',
browser: {
'nested-package': 'nested-browser-package'
}
'nested-package': 'nested-browser-package',
},
}),
'index.js': 'require("nested-package")',
},
@ -1884,11 +1884,11 @@ describe('DependencyGraph', function() {
'package.json': JSON.stringify({
'name': 'nested-browser-package',
}),
'index.js': 'some code'
}
}
}
}
'index.js': 'some code',
},
},
},
},
});
var dgraph = new DependencyGraph({

View File

@ -25,7 +25,7 @@ function extract(contents) {
}
var commentStartRe = /^\/\*\*?/;
var commentStartRe = /^\/\*\*/;
var commentEndRe = /\*\/$/;
var wsRe = /[\t ]+/g;
var stringStartRe = /(\r?\n|^) *\*/g;

View File

@ -15,7 +15,7 @@ class Package {
getMain() {
return this._read().then(json => {
var replacements = getReplacements(json)
var replacements = getReplacements(json);
if (typeof replacements === 'string') {
return path.join(this.root, replacements);
}

View File

@ -1,15 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
exports.IMPORT_RE = /(\bimport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g;
exports.EXPORT_RE = /(\bexport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g;
exports.REQUIRE_RE = /(\brequire\s*?\(\s*?)(['"])([^'"]+)(\2\s*?\))/g;
exports.SYSTEM_IMPORT_RE = /(\bSystem\.import\s*?\(\s*?)(['"])([^'"]+)(\2\s*?\))/g;