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(
[...dependencies].map(async path => {
const dep = dgraph.getModuleForPath(path);
const moduleDependencies = await dep.getDependencies();
const moduleDependencies = (await dep.read()).dependencies;
return {
path: dep.path,

View File

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

View File

@ -134,14 +134,6 @@ class Module {
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 {
// TODO: T26134860 Used for debugging purposes only; disabled with the new
// caches.
@ -177,10 +169,6 @@ class Module {
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
* itself that if a source code changed we won't return the cached transformed

View File

@ -209,11 +209,6 @@ describe('Module', () => {
createModule()
.read()
.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', () => {
@ -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'];
transformResult = {
code: exampleCode,
dependencies: mockedDependencies,
};
const module = createModule({transformCode});
const data = await module.read();
return module.getDependencies().then(dependencies => {
expect(dependencies).toEqual(mockedDependencies);
});
expect(data.dependencies).toEqual(mockedDependencies);
});
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};
const module = createModule({transformCode});
return Promise.all([module.read(), module.getCode()]).then(
([data, code]) => {
expect(data.code).toBe(exampleCode);
expect(code).toBe(exampleCode);
},
);
const data = await module.read();
expect(data.code).toBe(exampleCode);
});
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));
});
it('exposes a source map returned by the transform', () => {
it('exposes a source map returned by the transform', async () => {
const map = {version: 3};
transformResult = {map, code: exampleCode};
const module = createModule({transformCode});
return Promise.all([module.read(), module.getMap()]).then(
([data, sourceMap]) => {
expect(data.map).toBe(map);
expect(sourceMap).toBe(map);
},
);
const data = await module.read();
expect(data.map).toBe(map);
});
it('caches the transform result for the same transform options', () => {