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';
|
||||
|
||||
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 blacklist = require('./blacklist.js');
|
||||
var connect = require('connect');
|
||||
var http = require('http');
|
||||
var launchEditor = require('./launchEditor.js');
|
||||
var parseCommandLine = require('./parseCommandLine.js');
|
||||
var path = require('path');
|
||||
|
||||
var options = parseCommandLine([{
|
||||
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() {
|
||||
var root = '/root';
|
||||
fs.__setMockFilesystem({
|
||||
|
|
|
@ -267,9 +267,15 @@ DependecyGraph.prototype._findAndProcessPackage = function(files, root) {
|
|||
if (packagePath != null) {
|
||||
return readFile(packagePath, 'utf8')
|
||||
.then(function(content) {
|
||||
var packageJson = JSON.parse(content);
|
||||
if (packageJson.name == null) {
|
||||
var packageJson;
|
||||
try {
|
||||
packageJson = JSON.parse(content);
|
||||
} catch (e) {
|
||||
debug('WARNING: malformed package.json: ', packagePath);
|
||||
return q();
|
||||
}
|
||||
|
||||
if (packageJson.name == null) {
|
||||
debug(
|
||||
'WARNING: package.json `%s` is missing a name field',
|
||||
packagePath
|
||||
|
|
Loading…
Reference in New Issue