Skip to content

Commit

Permalink
refactor: make watchFolders read-only everywhere (react-native-commun…
Browse files Browse the repository at this point in the history
  • Loading branch information
fson authored Apr 25, 2020
1 parent bbb830e commit 5c83d59
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/cli-server-api/src/devToolsMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function escapePath(pathname: string) {
type LaunchDevToolsOptions = {
host?: string;
port: number;
watchFolders: Array<string>;
watchFolders: ReadonlyArray<string>;
};

function launchDevTools(
Expand All @@ -48,7 +48,7 @@ function startCustomDebugger({
watchFolders,
customDebugger,
}: {
watchFolders: Array<string>;
watchFolders: ReadonlyArray<string>;
customDebugger: string;
}) {
const folders = watchFolders.map(escapePath).join(' ');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-server-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export {messageSocketServer};

type MiddlewareOptions = {
host?: string;
watchFolders: Array<string>;
watchFolders: ReadonlyArray<string>;
port: number;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import connect from 'connect';
import rawBodyMiddleware from './rawBodyMiddleware';

type Options = {
watchFolders: Array<string>;
watchFolders: ReadonlyArray<string>;
};

function getOpenStackFrameInEditorMiddleware({watchFolders}: Options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import getDevToolsMiddleware from './getDevToolsMiddleware';

type Options = {
host?: string;
watchFolders: Array<string>;
watchFolders: ReadonlyArray<string>;
port: number;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function escapePath(pathname: string) {
type LaunchDevToolsOptions = {
host?: string;
port: number;
watchFolders: Array<string>;
watchFolders: ReadonlyArray<string>;
};

function launchDevTools(
Expand All @@ -48,7 +48,7 @@ function startCustomDebugger({
watchFolders,
customDebugger,
}: {
watchFolders: Array<string>;
watchFolders: ReadonlyArray<string>;
customDebugger: string;
}) {
const folders = watchFolders.map(escapePath).join(' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {launchEditor} from '@react-native-community/cli-tools';
export default function getOpenStackFrameInEditorMiddleware({
watchFolders,
}: {
watchFolders: Array<string>;
watchFolders: ReadonlyArray<string>;
}) {
return (
req: http.IncomingMessage & {rawBody: string},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/tools/loadMetroConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface MetroConfig {
assetRegistryPath: string;
assetPlugins?: Array<string>;
};
watchFolders: string[];
watchFolders: ReadonlyArray<string>;
reporter?: any;
}

Expand Down
7 changes: 5 additions & 2 deletions packages/tools/src/launchEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ function transformToAbsolutePathIfNeeded(pathName: string) {
return pathName;
}

function findRootForFile(projectRoots: string[], fileName: string) {
function findRootForFile(
projectRoots: ReadonlyArray<string>,
fileName: string,
) {
const absoluteFileName = transformToAbsolutePathIfNeeded(fileName);
return projectRoots.find(root => {
const absoluteRoot = transformToAbsolutePathIfNeeded(root);
Expand All @@ -165,7 +168,7 @@ let _childProcess: ChildProcess | null = null;
function launchEditor(
fileName: string,
lineNumber: number,
projectRoots: string[],
projectRoots: ReadonlyArray<string>,
) {
if (!fs.existsSync(fileName)) {
return;
Expand Down

0 comments on commit 5c83d59

Please sign in to comment.