Codemod to 1.7.0

Differential Revision: D5763302

fbshipit-source-id: a91ca1786c7ac8eb9aa3dd43555a7a223dc6f9cf
This commit is contained in:
Christopher Chedeau 2017-09-26 23:33:30 -07:00 committed by Facebook Github Bot
parent 23c69f5362
commit f4d9fccee6
10 changed files with 48 additions and 16 deletions

View File

@ -320,9 +320,12 @@ class Bundle extends BundleBase {
}
getEtag() {
/* $FlowFixMe: we must pass options, or rename the
* base `getSource` function, as it does not actually need options. */
var eTag = crypto.createHash('md5').update(this.getSource()).digest('hex');
var eTag = crypto
.createHash('md5')
/* $FlowFixMe: we must pass options, or rename the
* base `getSource` function, as it does not actually need options. */
.update(this.getSource())
.digest('hex');
return eTag;
}

View File

@ -295,7 +295,10 @@ describe('Bundler', function() {
'mockPlugin1',
() => {
return asset => {
asset.extraReverseHash = asset.hash.split('').reverse().join('');
asset.extraReverseHash = asset.hash
.split('')
.reverse()
.join('');
return asset;
};
},

View File

@ -180,7 +180,10 @@ class Bundler {
'metro-bundler-cache',
VERSION,
opts.cacheVersion,
stableProjectRoots.join(',').split(pathSeparator).join('-'),
stableProjectRoots
.join(',')
.split(pathSeparator)
.join('-'),
transformModuleHash,
];
@ -260,7 +263,10 @@ class Bundler {
* error found when Flow v0.54 was deployed. To see the error delete this
* comment and run Flow. */
return this._resolverPromise.then(resolver =>
resolver.getDependencyGraph().getWatcher().end(),
resolver
.getDependencyGraph()
.getWatcher()
.end(),
);
}

View File

@ -110,7 +110,10 @@ describe('Startup section optimization', () => {
codeOffset + startupSectionLength - 1,
);
expect(startupSection.toString()).toBe(
preloaded.concat([requireCall]).map(expectedCode).join('\n'),
preloaded
.concat([requireCall])
.map(expectedCode)
.join('\n'),
);
preloaded.forEach(m => {

View File

@ -12,7 +12,10 @@
'use strict';
jest.useRealTimers().unmock('fs').unmock('graceful-fs');
jest
.useRealTimers()
.unmock('fs')
.unmock('graceful-fs');
const Metro = require('../..');
const path = require('path');

View File

@ -266,7 +266,12 @@ class URIBasedGlobalTransformCache {
const cacheKey = props.getTransformCacheKey(transformOptions);
hash.update(JSON.stringify(cacheKey));
hash.update(JSON.stringify(localPath));
hash.update(crypto.createHash('sha1').update(sourceCode).digest('hex'));
hash.update(
crypto
.createHash('sha1')
.update(sourceCode)
.digest('hex'),
);
const digest = hash.digest('hex');
return `${digest}-${path.basename(localPath)}`;
}

View File

@ -192,7 +192,7 @@ class TerminalReporter {
if (error.code === 'EADDRINUSE') {
this.terminal.log(
chalk.bgRed.bold(' ERROR '),
chalk.red('Metro Bundler can\'t listen on port', chalk.bold(port)),
chalk.red("Metro Bundler can't listen on port", chalk.bold(port)),
);
this.terminal.log(
'Most likely another process is already using this port',

View File

@ -137,7 +137,10 @@ class FileBasedCache {
writeFileAtomicSync(
cacheFilePath.metadata,
JSON.stringify([
crypto.createHash('sha1').update(result.code).digest('hex'),
crypto
.createHash('sha1')
.update(result.code)
.digest('hex'),
hashSourceCode(props),
result.dependencies,
result.dependencyOffsets,

View File

@ -126,9 +126,11 @@ class DependencyGraph extends EventEmitter {
opts.reporter.update({type: 'dep_graph_loading'});
const haste = DependencyGraph._createHaste(opts);
const {hasteFS, moduleMap} = await haste.build();
log(createActionEndEntry(log(
createActionStartEntry('Initializing Metro Bundler'),
)));
log(
createActionEndEntry(
log(createActionStartEntry('Initializing Metro Bundler')),
),
);
opts.reporter.update({type: 'dep_graph_loaded'});
return new DependencyGraph({
haste,

View File

@ -163,10 +163,14 @@ describe('Module', () => {
});
it('exposes file contents as `code` property on the data exposed by `read()`', () =>
createModule().read().then(({code}) => expect(code).toBe(fileContents)));
createModule()
.read()
.then(({code}) => expect(code).toBe(fileContents)));
it('exposes file contents via the `getCode()` method', () =>
createModule().getCode().then(code => expect(code).toBe(fileContents)));
createModule()
.getCode()
.then(code => expect(code).toBe(fileContents)));
});
describe('Custom Code Transform', () => {