Fix flow errors

Reviewed By: davidaurelio

Differential Revision: D4619990

fbshipit-source-id: 80355b8f0d0c3f84691098a05cdf2ba136c4bf53
This commit is contained in:
Christoph Pojer 2017-02-27 08:00:08 -08:00 committed by Facebook Github Bot
parent 20ad2b3fbb
commit 37b91a63c7
5 changed files with 12 additions and 7 deletions

View File

@ -23,7 +23,6 @@ const HMRBundle = require('./HMRBundle');
const ModuleTransport = require('../lib/ModuleTransport'); const ModuleTransport = require('../lib/ModuleTransport');
const imageSize = require('image-size'); const imageSize = require('image-size');
const path = require('path'); const path = require('path');
const version = require('../../../package.json').version;
const denodeify = require('denodeify'); const denodeify = require('denodeify');
const { const {
@ -34,6 +33,8 @@ const {
extname, extname,
} = require('path'); } = require('path');
const VERSION = require('../../package.json').version;
import type AssetServer from '../AssetServer'; import type AssetServer from '../AssetServer';
import type Module from '../node-haste/Module'; import type Module from '../node-haste/Module';
import type ResolutionResponse from '../node-haste/DependencyGraph/ResolutionResponse'; import type ResolutionResponse from '../node-haste/DependencyGraph/ResolutionResponse';
@ -129,7 +130,7 @@ class Bundler {
const cacheKeyParts = [ const cacheKeyParts = [
'react-packager-cache', 'react-packager-cache',
version, VERSION,
opts.cacheVersion, opts.cacheVersion,
stableProjectRoots.join(',').split(pathSeparator).join('-'), stableProjectRoots.join(',').split(pathSeparator).join('-'),
transformModuleHash, transformModuleHash,

View File

@ -12,10 +12,11 @@
'use strict'; 'use strict';
const os = require('os'); const os = require('os');
const pkgjson = require('../../../package.json');
const {EventEmitter} = require('events'); const {EventEmitter} = require('events');
const VERSION = require('../../package.json').version;
import type { import type {
ActionLogEntryData, ActionLogEntryData,
ActionStartLogEntry, ActionStartLogEntry,
@ -35,7 +36,7 @@ function createEntry(data: LogEntry | string): LogEntry {
return { return {
...logEntry, ...logEntry,
log_session, log_session,
packager_version: pkgjson.version, packager_version: VERSION,
}; };
} }

View File

@ -11,6 +11,7 @@
'use strict'; 'use strict';
const nullthrows = require('fbjs/lib/nullthrows');
const path = require('path'); const path = require('path');
import type {PackageData} from '../types.flow'; import type {PackageData} from '../types.flow';
@ -51,7 +52,7 @@ module.exports = class Package {
} }
getName() { getName() {
return this.data.then(p => p.name); return this.data.then(p => nullthrows(p.name));
} }
isHaste() { isHaste() {

View File

@ -10,7 +10,9 @@
* @flow * @flow
*/ */
'use strict'; 'use strict';
declare var __DEV__: boolean;
type DependencyMap = Array<ModuleID>; type DependencyMap = Array<ModuleID>;
type Exports = any; type Exports = any;

View File

@ -236,7 +236,7 @@ function loadCacheSync(cachePath) {
} }
try { try {
return JSON.parse(fs.readFileSync(cachePath)); return JSON.parse(fs.readFileSync(cachePath, 'utf8'));
} catch (e) { } catch (e) {
if (e instanceof SyntaxError) { if (e instanceof SyntaxError) {
console.warn('Unable to parse cache file. Will clear and continue.'); console.warn('Unable to parse cache file. Will clear and continue.');