mirror of https://github.com/status-im/metro.git
Codemod to 1.7.0
Differential Revision: D5763302 fbshipit-source-id: a91ca1786c7ac8eb9aa3dd43555a7a223dc6f9cf
This commit is contained in:
parent
23c69f5362
commit
f4d9fccee6
|
@ -320,9 +320,12 @@ class Bundle extends BundleBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
getEtag() {
|
getEtag() {
|
||||||
|
var eTag = crypto
|
||||||
|
.createHash('md5')
|
||||||
/* $FlowFixMe: we must pass options, or rename the
|
/* $FlowFixMe: we must pass options, or rename the
|
||||||
* base `getSource` function, as it does not actually need options. */
|
* base `getSource` function, as it does not actually need options. */
|
||||||
var eTag = crypto.createHash('md5').update(this.getSource()).digest('hex');
|
.update(this.getSource())
|
||||||
|
.digest('hex');
|
||||||
return eTag;
|
return eTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,10 @@ describe('Bundler', function() {
|
||||||
'mockPlugin1',
|
'mockPlugin1',
|
||||||
() => {
|
() => {
|
||||||
return asset => {
|
return asset => {
|
||||||
asset.extraReverseHash = asset.hash.split('').reverse().join('');
|
asset.extraReverseHash = asset.hash
|
||||||
|
.split('')
|
||||||
|
.reverse()
|
||||||
|
.join('');
|
||||||
return asset;
|
return asset;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -180,7 +180,10 @@ class Bundler {
|
||||||
'metro-bundler-cache',
|
'metro-bundler-cache',
|
||||||
VERSION,
|
VERSION,
|
||||||
opts.cacheVersion,
|
opts.cacheVersion,
|
||||||
stableProjectRoots.join(',').split(pathSeparator).join('-'),
|
stableProjectRoots
|
||||||
|
.join(',')
|
||||||
|
.split(pathSeparator)
|
||||||
|
.join('-'),
|
||||||
transformModuleHash,
|
transformModuleHash,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -260,7 +263,10 @@ class Bundler {
|
||||||
* error found when Flow v0.54 was deployed. To see the error delete this
|
* error found when Flow v0.54 was deployed. To see the error delete this
|
||||||
* comment and run Flow. */
|
* comment and run Flow. */
|
||||||
return this._resolverPromise.then(resolver =>
|
return this._resolverPromise.then(resolver =>
|
||||||
resolver.getDependencyGraph().getWatcher().end(),
|
resolver
|
||||||
|
.getDependencyGraph()
|
||||||
|
.getWatcher()
|
||||||
|
.end(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,10 @@ describe('Startup section optimization', () => {
|
||||||
codeOffset + startupSectionLength - 1,
|
codeOffset + startupSectionLength - 1,
|
||||||
);
|
);
|
||||||
expect(startupSection.toString()).toBe(
|
expect(startupSection.toString()).toBe(
|
||||||
preloaded.concat([requireCall]).map(expectedCode).join('\n'),
|
preloaded
|
||||||
|
.concat([requireCall])
|
||||||
|
.map(expectedCode)
|
||||||
|
.join('\n'),
|
||||||
);
|
);
|
||||||
|
|
||||||
preloaded.forEach(m => {
|
preloaded.forEach(m => {
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.useRealTimers().unmock('fs').unmock('graceful-fs');
|
jest
|
||||||
|
.useRealTimers()
|
||||||
|
.unmock('fs')
|
||||||
|
.unmock('graceful-fs');
|
||||||
|
|
||||||
const Metro = require('../..');
|
const Metro = require('../..');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
|
@ -266,7 +266,12 @@ class URIBasedGlobalTransformCache {
|
||||||
const cacheKey = props.getTransformCacheKey(transformOptions);
|
const cacheKey = props.getTransformCacheKey(transformOptions);
|
||||||
hash.update(JSON.stringify(cacheKey));
|
hash.update(JSON.stringify(cacheKey));
|
||||||
hash.update(JSON.stringify(localPath));
|
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');
|
const digest = hash.digest('hex');
|
||||||
return `${digest}-${path.basename(localPath)}`;
|
return `${digest}-${path.basename(localPath)}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ class TerminalReporter {
|
||||||
if (error.code === 'EADDRINUSE') {
|
if (error.code === 'EADDRINUSE') {
|
||||||
this.terminal.log(
|
this.terminal.log(
|
||||||
chalk.bgRed.bold(' ERROR '),
|
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(
|
this.terminal.log(
|
||||||
'Most likely another process is already using this port',
|
'Most likely another process is already using this port',
|
||||||
|
|
|
@ -137,7 +137,10 @@ class FileBasedCache {
|
||||||
writeFileAtomicSync(
|
writeFileAtomicSync(
|
||||||
cacheFilePath.metadata,
|
cacheFilePath.metadata,
|
||||||
JSON.stringify([
|
JSON.stringify([
|
||||||
crypto.createHash('sha1').update(result.code).digest('hex'),
|
crypto
|
||||||
|
.createHash('sha1')
|
||||||
|
.update(result.code)
|
||||||
|
.digest('hex'),
|
||||||
hashSourceCode(props),
|
hashSourceCode(props),
|
||||||
result.dependencies,
|
result.dependencies,
|
||||||
result.dependencyOffsets,
|
result.dependencyOffsets,
|
||||||
|
|
|
@ -126,9 +126,11 @@ class DependencyGraph extends EventEmitter {
|
||||||
opts.reporter.update({type: 'dep_graph_loading'});
|
opts.reporter.update({type: 'dep_graph_loading'});
|
||||||
const haste = DependencyGraph._createHaste(opts);
|
const haste = DependencyGraph._createHaste(opts);
|
||||||
const {hasteFS, moduleMap} = await haste.build();
|
const {hasteFS, moduleMap} = await haste.build();
|
||||||
log(createActionEndEntry(log(
|
log(
|
||||||
createActionStartEntry('Initializing Metro Bundler'),
|
createActionEndEntry(
|
||||||
)));
|
log(createActionStartEntry('Initializing Metro Bundler')),
|
||||||
|
),
|
||||||
|
);
|
||||||
opts.reporter.update({type: 'dep_graph_loaded'});
|
opts.reporter.update({type: 'dep_graph_loaded'});
|
||||||
return new DependencyGraph({
|
return new DependencyGraph({
|
||||||
haste,
|
haste,
|
||||||
|
|
|
@ -163,10 +163,14 @@ describe('Module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('exposes file contents as `code` property on the data exposed by `read()`', () =>
|
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', () =>
|
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', () => {
|
describe('Custom Code Transform', () => {
|
||||||
|
|
Loading…
Reference in New Issue