Get rid of unused methods

Reviewed By: davidaurelio

Differential Revision: D7169707

fbshipit-source-id: 8b29791e15631a3ee4674a6cb5046e675c2c3727
This commit is contained in:
Miguel Jimenez Esun 2018-03-07 06:45:06 -08:00 committed by Facebook Github Bot
parent 243fe983b7
commit aaedb99ac4
4 changed files with 18 additions and 41 deletions

View File

@ -75,7 +75,7 @@ describe('traverseDependencies', function() {
return await Promise.all( return await Promise.all(
[...dependencies].map(async path => { [...dependencies].map(async path => {
const dep = dgraph.getModuleForPath(path); const dep = dgraph.getModuleForPath(path);
const moduleDependencies = await dep.getDependencies(); const moduleDependencies = (await dep.read()).dependencies;
return { return {
path: dep.path, path: dep.path,

View File

@ -222,13 +222,14 @@ class DependencyGraph extends EventEmitter {
* Returns a promise with the direct dependencies the module associated to * Returns a promise with the direct dependencies the module associated to
* the given entryPath has. * the given entryPath has.
*/ */
getShallowDependencies( async getShallowDependencies(
entryPath: string, entryPath: string,
transformOptions: JSTransformerOptions, transformOptions: JSTransformerOptions,
): Promise<Array<string>> { ): Promise<$ReadOnlyArray<string>> {
return this._moduleCache const module = this._moduleCache.getModule(entryPath);
.getModule(entryPath) const result = await module.read(transformOptions);
.getDependencies(transformOptions);
return result.dependencies;
} }
getWatcher() { getWatcher() {

View File

@ -134,14 +134,6 @@ class Module {
return this._getHasteName() != null; return this._getHasteName() != null;
} }
async getCode(transformOptions: WorkerOptions): Promise<string> {
return (await this.read(transformOptions)).code;
}
async getMap(transformOptions: WorkerOptions) {
return (await this.read(transformOptions)).map;
}
getName(): string { getName(): string {
// TODO: T26134860 Used for debugging purposes only; disabled with the new // TODO: T26134860 Used for debugging purposes only; disabled with the new
// caches. // caches.
@ -177,10 +169,6 @@ class Module {
return this._moduleCache.getPackageForModule(this); return this._moduleCache.getPackageForModule(this);
} }
async getDependencies(transformOptions: WorkerOptions) {
return (await this.read(transformOptions)).dependencies;
}
/** /**
* We don't need to invalidate the TranformCache itself because it guarantees * We don't need to invalidate the TranformCache itself because it guarantees
* itself that if a source code changed we won't return the cached transformed * itself that if a source code changed we won't return the cached transformed

View File

@ -209,11 +209,6 @@ describe('Module', () => {
createModule() createModule()
.read() .read()
.then(({code}) => expect(code).toBe(fileContents))); .then(({code}) => expect(code).toBe(fileContents)));
it('exposes file contents via the `getCode()` method', () =>
createModule()
.getCode()
.then(code => expect(code).toBe(fileContents)));
}); });
describe('Custom Code Transform', () => { describe('Custom Code Transform', () => {
@ -276,17 +271,16 @@ describe('Module', () => {
}); });
}); });
it('uses dependencies that `transformCode` resolves to, instead of extracting them', () => { it('uses dependencies that `transformCode` resolves to, instead of extracting them', async () => {
const mockedDependencies = ['foo', 'bar']; const mockedDependencies = ['foo', 'bar'];
transformResult = { transformResult = {
code: exampleCode, code: exampleCode,
dependencies: mockedDependencies, dependencies: mockedDependencies,
}; };
const module = createModule({transformCode}); const module = createModule({transformCode});
const data = await module.read();
return module.getDependencies().then(dependencies => { expect(data.dependencies).toEqual(mockedDependencies);
expect(dependencies).toEqual(mockedDependencies);
});
}); });
it('forwards all additional properties of the result provided by `transformCode`', () => { it('forwards all additional properties of the result provided by `transformCode`', () => {
@ -304,15 +298,12 @@ describe('Module', () => {
}); });
}); });
it('exposes the transformed code rather than the raw file contents', () => { it('exposes the transformed code rather than the raw file contents', async () => {
transformResult = {code: exampleCode}; transformResult = {code: exampleCode};
const module = createModule({transformCode}); const module = createModule({transformCode});
return Promise.all([module.read(), module.getCode()]).then( const data = await module.read();
([data, code]) => {
expect(data.code).toBe(exampleCode); expect(data.code).toBe(exampleCode);
expect(code).toBe(exampleCode);
},
);
}); });
it('exposes the raw file contents as `source` property', () => { it('exposes the raw file contents as `source` property', () => {
@ -320,16 +311,13 @@ describe('Module', () => {
return module.read().then(data => expect(data.source).toBe(fileContents)); return module.read().then(data => expect(data.source).toBe(fileContents));
}); });
it('exposes a source map returned by the transform', () => { it('exposes a source map returned by the transform', async () => {
const map = {version: 3}; const map = {version: 3};
transformResult = {map, code: exampleCode}; transformResult = {map, code: exampleCode};
const module = createModule({transformCode}); const module = createModule({transformCode});
return Promise.all([module.read(), module.getMap()]).then( const data = await module.read();
([data, sourceMap]) => {
expect(data.map).toBe(map); expect(data.map).toBe(map);
expect(sourceMap).toBe(map);
},
);
}); });
it('caches the transform result for the same transform options', () => { it('caches the transform result for the same transform options', () => {