From c948ae81686e2345d155577b4ff9f43f50021e99 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Wed, 10 May 2017 03:33:26 -0700 Subject: [PATCH] packager: rename node-haste/index to DependencyGraph Summary: I've been confused for a long time by this, and I think it's better late than never. I propose we rename that file to make it more explicit where that class lives, and so that it's consistent with the test file, name `DependencyGraph-test.js` Reviewed By: davidaurelio Differential Revision: D5020556 fbshipit-source-id: d54a501c3995f3fea16a5bfc6ca72993f73c4873 --- local-cli/server/util/attachHMRServer.js | 2 +- .../AssetServer/__tests__/AssetServer-test.js | 2 +- packager/src/AssetServer/index.js | 2 +- packager/src/Bundler/__tests__/Bundler-test.js | 2 +- .../src/Resolver/__tests__/Resolver-test.js | 2 +- packager/src/Resolver/index.js | 2 +- packager/src/Server/__tests__/Server-test.js | 2 +- packager/src/Server/index.js | 2 +- .../{index.js => DependencyGraph.js} | 0 .../__tests__/DependencyGraph-test.js | 18 +++++++++--------- 10 files changed, 17 insertions(+), 17 deletions(-) rename packager/src/node-haste/{index.js => DependencyGraph.js} (100%) diff --git a/local-cli/server/util/attachHMRServer.js b/local-cli/server/util/attachHMRServer.js index e9094ac3c..bed4c1d84 100644 --- a/local-cli/server/util/attachHMRServer.js +++ b/local-cli/server/util/attachHMRServer.js @@ -14,7 +14,7 @@ const querystring = require('querystring'); const url = require('url'); -const {getInverseDependencies} = require('../../../packager/src//node-haste'); +const {getInverseDependencies} = require('../../../packager/src//node-haste/DependencyGraph'); import type HMRBundle from '../../../packager/src/Bundler/HMRBundle'; import type Server from '../../../packager/src/Server'; diff --git a/packager/src/AssetServer/__tests__/AssetServer-test.js b/packager/src/AssetServer/__tests__/AssetServer-test.js index d03cbd1fb..5b9ca19fb 100644 --- a/packager/src/AssetServer/__tests__/AssetServer-test.js +++ b/packager/src/AssetServer/__tests__/AssetServer-test.js @@ -21,7 +21,7 @@ const {objectContaining} = jasmine; describe('AssetServer', () => { beforeEach(() => { - const NodeHaste = require('../../node-haste'); + const NodeHaste = require('../../node-haste/DependencyGraph'); NodeHaste.getAssetDataFromName = require.requireActual('../../node-haste/lib/getAssetDataFromName'); }); diff --git a/packager/src/AssetServer/index.js b/packager/src/AssetServer/index.js index c18caa3af..e2ffd01ca 100644 --- a/packager/src/AssetServer/index.js +++ b/packager/src/AssetServer/index.js @@ -14,7 +14,7 @@ const crypto = require('crypto'); const denodeify = require('denodeify'); const fs = require('fs'); -const getAssetDataFromName = require('../node-haste').getAssetDataFromName; +const getAssetDataFromName = require('../node-haste/DependencyGraph').getAssetDataFromName; const path = require('path'); import type {AssetData} from '../node-haste/lib/getAssetDataFromName'; diff --git a/packager/src/Bundler/__tests__/Bundler-test.js b/packager/src/Bundler/__tests__/Bundler-test.js index dcea0d6e1..a8924a4fe 100644 --- a/packager/src/Bundler/__tests__/Bundler-test.js +++ b/packager/src/Bundler/__tests__/Bundler-test.js @@ -19,7 +19,7 @@ jest .mock('os') .mock('assert') .mock('progress') - .mock('../../node-haste') + .mock('../../node-haste/DependencyGraph') .mock('../../JSTransformer') .mock('../../lib/declareOpts') .mock('../../Resolver') diff --git a/packager/src/Resolver/__tests__/Resolver-test.js b/packager/src/Resolver/__tests__/Resolver-test.js index dce69acfa..67ec8ab81 100644 --- a/packager/src/Resolver/__tests__/Resolver-test.js +++ b/packager/src/Resolver/__tests__/Resolver-test.js @@ -16,7 +16,7 @@ jest.mock('path'); const {join: pathJoin} = require.requireActual('path'); const DependencyGraph = jest.fn(); -jest.setMock('../../node-haste', DependencyGraph); +jest.setMock('../../node-haste/DependencyGraph', DependencyGraph); let Module; let Polyfill; diff --git a/packager/src/Resolver/index.js b/packager/src/Resolver/index.js index ea2bd23cb..77c8f0b8b 100644 --- a/packager/src/Resolver/index.js +++ b/packager/src/Resolver/index.js @@ -11,7 +11,7 @@ 'use strict'; -const DependencyGraph = require('../node-haste'); +const DependencyGraph = require('../node-haste/DependencyGraph'); const defaults = require('../../defaults'); const pathJoin = require('path').join; diff --git a/packager/src/Server/__tests__/Server-test.js b/packager/src/Server/__tests__/Server-test.js index ce21478f4..d98072883 100644 --- a/packager/src/Server/__tests__/Server-test.js +++ b/packager/src/Server/__tests__/Server-test.js @@ -23,7 +23,7 @@ jest.mock('../../worker-farm', () => () => () => {}) .mock('../../Bundler') .mock('../../AssetServer') .mock('../../lib/declareOpts') - .mock('../../node-haste') + .mock('../../node-haste/DependencyGraph') .mock('../../Logger') .mock('../../lib/GlobalTransformCache'); diff --git a/packager/src/Server/index.js b/packager/src/Server/index.js index 4344cd287..9fb3fe80b 100644 --- a/packager/src/Server/index.js +++ b/packager/src/Server/index.js @@ -12,7 +12,7 @@ 'use strict'; const AssetServer = require('../AssetServer'); -const getPlatformExtension = require('../node-haste').getPlatformExtension; +const getPlatformExtension = require('../node-haste/DependencyGraph').getPlatformExtension; const Bundler = require('../Bundler'); const MultipartResponse = require('./MultipartResponse'); diff --git a/packager/src/node-haste/index.js b/packager/src/node-haste/DependencyGraph.js similarity index 100% rename from packager/src/node-haste/index.js rename to packager/src/node-haste/DependencyGraph.js diff --git a/packager/src/node-haste/__tests__/DependencyGraph-test.js b/packager/src/node-haste/__tests__/DependencyGraph-test.js index 857849ec0..7b6c536ad 100644 --- a/packager/src/node-haste/__tests__/DependencyGraph-test.js +++ b/packager/src/node-haste/__tests__/DependencyGraph-test.js @@ -106,7 +106,7 @@ describe('DependencyGraph', function() { const realPlatform = process.platform; beforeEach(function() { process.platform = 'linux'; - DependencyGraph = require('../index'); + DependencyGraph = require('../DependencyGraph'); }); afterEach(function() { @@ -2368,7 +2368,7 @@ describe('DependencyGraph', function() { // reload path module jest.resetModules(); jest.mock('path', () => path.win32); - DependencyGraph = require('../index'); + DependencyGraph = require('../DependencyGraph'); }); afterEach(function() { @@ -2559,7 +2559,7 @@ describe('DependencyGraph', function() { let DependencyGraph; beforeEach(function() { process.platform = 'linux'; - DependencyGraph = require('../index'); + DependencyGraph = require('../DependencyGraph'); }); afterEach(function() { @@ -3539,7 +3539,7 @@ describe('DependencyGraph', function() { // due to the drive letter expectation if (realPlatform !== 'win32') { return; } - const DependencyGraph = require('../index'); + const DependencyGraph = require('../DependencyGraph'); it('should work with nested node_modules', function() { var root = '/root'; @@ -4503,7 +4503,7 @@ describe('DependencyGraph', function() { beforeEach(function() { process.platform = 'linux'; - DependencyGraph = require('../index'); + DependencyGraph = require('../DependencyGraph'); }); afterEach(function() { @@ -5221,7 +5221,7 @@ describe('DependencyGraph', function() { let DependencyGraph; beforeEach(function() { process.platform = 'linux'; - DependencyGraph = require('../index'); + DependencyGraph = require('../DependencyGraph'); }); afterEach(function() { @@ -5393,7 +5393,7 @@ describe('DependencyGraph', function() { 'g.js': makeModule('g'), }, }); - const DependencyGraph = require('../'); + const DependencyGraph = require('../DependencyGraph'); return DependencyGraph.load({ ...defaults, roots: ['/root'], @@ -5424,7 +5424,7 @@ describe('DependencyGraph', function() { describe('Asset module dependencies', () => { let DependencyGraph; beforeEach(() => { - DependencyGraph = require('../index'); + DependencyGraph = require('../DependencyGraph'); }); it('allows setting dependencies for asset modules', () => { @@ -5460,7 +5460,7 @@ describe('DependencyGraph', function() { beforeEach(() => { moduleRead = Module.prototype.read; - DependencyGraph = require('../index'); + DependencyGraph = require('../DependencyGraph'); setMockFileSystem({ 'root': { 'index.js': `