mirror of https://github.com/status-im/metro.git
2015-02-07 updates
- Random little fixes | Andres Suarez - Add backButtonTitle to Navigator | Nick Poulden - [react-pacakger] Ignore malformed package.json | Amjad Masad - Renamed hasMove to hasMark | Rich Seymour - Update XMLHttpRequest.ios.js | Nick Poulden - Warn about missing dependencies for issue #16 | Andrew McCloud
This commit is contained in:
parent
931041f3d2
commit
63e329e388
14
packager.js
14
packager.js
|
@ -3,13 +3,25 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
if (!fs.existsSync(path.resolve(__dirname, '..', 'node_modules'))) {
|
||||||
|
console.log(
|
||||||
|
'\n' +
|
||||||
|
'Could not find dependencies.\n' +
|
||||||
|
'Ensure dependencies are installed - ' +
|
||||||
|
'run \'npm install\' from project root.\n'
|
||||||
|
);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
var ReactPackager = require('./react-packager');
|
var ReactPackager = require('./react-packager');
|
||||||
var blacklist = require('./blacklist.js');
|
var blacklist = require('./blacklist.js');
|
||||||
var connect = require('connect');
|
var connect = require('connect');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var launchEditor = require('./launchEditor.js');
|
var launchEditor = require('./launchEditor.js');
|
||||||
var parseCommandLine = require('./parseCommandLine.js');
|
var parseCommandLine = require('./parseCommandLine.js');
|
||||||
var path = require('path');
|
|
||||||
|
|
||||||
var options = parseCommandLine([{
|
var options = parseCommandLine([{
|
||||||
command: 'port',
|
command: 'port',
|
||||||
|
|
|
@ -122,6 +122,32 @@ describe('DependencyGraph', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pit('should ignore malformed packages', function() {
|
||||||
|
var root = '/root';
|
||||||
|
fs.__setMockFilesystem({
|
||||||
|
'root': {
|
||||||
|
'index.js': [
|
||||||
|
'/**',
|
||||||
|
' * @providesModule index',
|
||||||
|
' */',
|
||||||
|
'require("aPackage")',
|
||||||
|
].join('\n'),
|
||||||
|
'aPackage': {
|
||||||
|
'package.json': 'lol',
|
||||||
|
'main.js': 'lol'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var dgraph = new DependencyGraph({roots: [root], fileWatcher: fileWatcher});
|
||||||
|
return dgraph.load().then(function() {
|
||||||
|
expect(dgraph.getOrderedDependencies('/root/index.js'))
|
||||||
|
.toEqual([
|
||||||
|
{id: 'index', path: '/root/index.js', dependencies: ['aPackage']},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
pit('can have multiple modules with the same name', function() {
|
pit('can have multiple modules with the same name', function() {
|
||||||
var root = '/root';
|
var root = '/root';
|
||||||
fs.__setMockFilesystem({
|
fs.__setMockFilesystem({
|
||||||
|
|
|
@ -267,9 +267,15 @@ DependecyGraph.prototype._findAndProcessPackage = function(files, root) {
|
||||||
if (packagePath != null) {
|
if (packagePath != null) {
|
||||||
return readFile(packagePath, 'utf8')
|
return readFile(packagePath, 'utf8')
|
||||||
.then(function(content) {
|
.then(function(content) {
|
||||||
var packageJson = JSON.parse(content);
|
var packageJson;
|
||||||
if (packageJson.name == null) {
|
try {
|
||||||
|
packageJson = JSON.parse(content);
|
||||||
|
} catch (e) {
|
||||||
|
debug('WARNING: malformed package.json: ', packagePath);
|
||||||
|
return q();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packageJson.name == null) {
|
||||||
debug(
|
debug(
|
||||||
'WARNING: package.json `%s` is missing a name field',
|
'WARNING: package.json `%s` is missing a name field',
|
||||||
packagePath
|
packagePath
|
||||||
|
|
Loading…
Reference in New Issue