Skip to content

Commit

Permalink
Move FsUtils to fsUtils.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
digeff committed Sep 17, 2020
1 parent cd97c2c commit 0c8afe0
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 23 deletions.
9 changes: 7 additions & 2 deletions src/common/fsUtils.ts
Expand Up @@ -111,6 +111,11 @@ export interface IFsUtils {
exists(path: string): Promise<boolean>;
}

/**
* Injection for the `IFsUtils` interface.
*/
export const FSUtils = Symbol('FsUtils');

export class LocalFsUtils implements IFsUtils {
public constructor(private readonly fs: FsPromises) {}

Expand All @@ -120,8 +125,8 @@ export class LocalFsUtils implements IFsUtils {
if (process.platform === 'darwin') {
return fs.existsSync(path); // One of the unit tests fails on OSX
} else {
await this.fs.access(path, fs.constants.F_OK);
return true;
await this.fs.access(path, fs.constants.F_OK);
return true;
}
} catch {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Expand Up @@ -5,9 +5,9 @@
import { tmpdir } from 'os';
import * as vscode from 'vscode';
import { allDebugTypes, Commands, registerCommand } from './common/contributionUtils';
import { FSUtils } from './common/fsUtils';
import { extensionId } from './configuration';
import { createGlobalContainer } from './ioc';
import { FSUtils } from './ioc-extras';
import { DelegateLauncherFactory } from './targets/delegate/delegateLauncherFactory';
import { registerAutoAttach } from './ui/autoAttach';
import { CascadeTerminationTracker } from './ui/cascadeTerminateTracker';
Expand Down
5 changes: 0 additions & 5 deletions src/ioc-extras.ts
Expand Up @@ -53,11 +53,6 @@ export const Execa = Symbol('execa');
*/
export const FS = Symbol('FS');

/**
* Injection for the `FsUtils` module.
*/
export const FSUtils = Symbol('FsUtils');

/**
* Location the extension is running.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/ioc.ts
Expand Up @@ -43,7 +43,7 @@ import { ICdpApi } from './cdp/connection';
import { ObservableMap } from './common/datastructure/observableMap';
import { DefaultBrowserProvider, IDefaultBrowserProvider } from './common/defaultBrowserProvider';
import { OutFiles, VueComponentPaths } from './common/fileGlobList';
import { LocalAndRemoteFsUtils, LocalFsUtils } from './common/fsUtils';
import { FSUtils, LocalAndRemoteFsUtils, LocalFsUtils } from './common/fsUtils';
import { ILogger } from './common/logging';
import { Logger } from './common/logging/logger';
import { CodeSearchStrategy } from './common/sourceMaps/codeSearchStrategy';
Expand All @@ -59,7 +59,6 @@ import {
ExtensionContext,
ExtensionLocation,
FS,
FSUtils,
IContainer,
IsVSCode,
ProcessEnv,
Expand Down
2 changes: 1 addition & 1 deletion src/targets/browser/browserPathResolver.ts
Expand Up @@ -24,7 +24,7 @@ import { injectable, inject } from 'inversify';
import { IVueFileMapper, VueHandling } from '../../adapter/vueFileMapper';
import { ILogger } from '../../common/logging';
import { IFsUtils } from '../../common/fsUtils';
import { FSUtils } from '../../ioc-extras';
import { FSUtils } from '../../common/fsUtils';

interface IOptions extends ISourcePathResolverOptions {
baseUrl?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/targets/node/autoAttachLauncher.ts
Expand Up @@ -16,7 +16,7 @@ import { forceForwardSlashes } from '../../common/pathUtils';
import { AnyLaunchConfiguration, ITerminalLaunchConfiguration } from '../../configuration';
import { ErrorCodes } from '../../dap/errors';
import { ProtocolError } from '../../dap/protocolError';
import { ExtensionContext, FS, FsPromises, FSUtils } from '../../ioc-extras';
import { ExtensionContext, FS, FsPromises } from '../../ioc-extras';
import { ITarget } from '../targets';
import {
BootloaderEnvironment,
Expand All @@ -35,7 +35,7 @@ import { IProcessTelemetry, IRunData, NodeLauncherBase } from './nodeLauncherBas
import { StubProgram } from './program';
import { ITerminalLauncherLike } from './terminalNodeLauncher';
import { WatchDog } from './watchdogSpawn';
import { LocalFsUtils } from '../../common/fsUtils';
import { FSUtils, LocalFsUtils } from '../../common/fsUtils';

/**
* A special launcher whose launchProgram is a no-op. Used in attach attachment
Expand Down
2 changes: 1 addition & 1 deletion src/targets/node/nodeAttacher.ts
Expand Up @@ -23,7 +23,7 @@ import { IProgram, StubProgram, WatchDogProgram } from './program';
import { IRestartPolicy, RestartPolicyFactory } from './restartPolicy';
import { WatchDog } from './watchdogSpawn';
import { LocalFsUtils } from '../../common/fsUtils';
import { FSUtils } from '../../ioc-extras';
import { FSUtils } from '../../common/fsUtils';

const localize = nls.loadMessageBundle();

Expand Down
2 changes: 1 addition & 1 deletion src/targets/node/nodeLauncher.ts
Expand Up @@ -28,7 +28,7 @@ import { IProgramLauncher } from './processLauncher';
import { CombinedProgram, WatchDogProgram } from './program';
import { IRestartPolicy, RestartPolicyFactory } from './restartPolicy';
import { WatchDog } from './watchdogSpawn';
import { FSUtils } from '../../ioc-extras';
import { FSUtils } from '../../common/fsUtils';

/**
* Tries to get the "program" entrypoint from the config. It a program
Expand Down
2 changes: 1 addition & 1 deletion src/targets/node/nodeLauncherBase.ts
Expand Up @@ -42,7 +42,7 @@ import {
import { NodeSourcePathResolver } from './nodeSourcePathResolver';
import { INodeTargetLifecycleHooks, NodeTarget } from './nodeTarget';
import { IProgram } from './program';
import { FSUtils } from '../../ioc-extras';
import { FSUtils } from '../../common/fsUtils';
import { IFsUtils } from '../../common/fsUtils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/targets/node/nvmResolver.ts
Expand Up @@ -10,7 +10,7 @@ import { inject, injectable } from 'inversify';
import { some } from '../../common/promiseUtil';
import { LocalFsUtils } from '../../common/fsUtils';
import { promises as fsPromises } from 'fs';
import { FSUtils } from '../../ioc-extras';
import { FSUtils } from '../../common/fsUtils';

/**
* Resolves the location of Node installation querying an nvm installation.
Expand Down
4 changes: 2 additions & 2 deletions src/targets/node/terminalNodeLauncher.ts
Expand Up @@ -12,15 +12,15 @@ import { ErrorCodes } from '../../dap/errors';
import { ProtocolError } from '../../dap/protocolError';
import { tmpdir } from 'os';
import { randomBytes } from 'crypto';
import { FS, FsPromises, FSUtils } from '../../ioc-extras';
import { FS, FsPromises } from '../../ioc-extras';
import {
hideDebugInfoFromConsole,
INodeBinaryProvider,
NodeBinaryProvider,
NodeBinary,
} from './nodeBinaryProvider';
import { ILogger } from '../../common/logging';
import { IFsUtils } from '../../common/fsUtils';
import { FSUtils, IFsUtils } from '../../common/fsUtils';
import { IProgram } from './program';
import { IStopMetadata, ITarget } from '../targets';
import { NodeLauncherBase, IProcessTelemetry, IRunData } from './nodeLauncherBase';
Expand Down
4 changes: 2 additions & 2 deletions src/targets/sourcePathResolverFactory.ts
Expand Up @@ -10,9 +10,9 @@ import { AnyLaunchConfiguration } from '../configuration';
import Dap from '../dap/api';
import { baseURL } from './browser/browserLaunchParams';
import { BrowserSourcePathResolver } from './browser/browserPathResolver';
import { IInitializeParams, FSUtils } from '../ioc-extras';
import { IInitializeParams } from '../ioc-extras';
import { NodeSourcePathResolver } from './node/nodeSourcePathResolver';
import { LocalFsUtils } from '../common/fsUtils';
import { FSUtils, LocalFsUtils } from '../common/fsUtils';

@injectable()
export class SourcePathResolverFactory {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/configuration/nodeDebugConfigurationResolver.ts
Expand Up @@ -23,12 +23,12 @@ import {
ResolvingNodeAttachConfiguration,
ResolvingNodeLaunchConfiguration,
} from '../../configuration';
import { ExtensionContext, FSUtils } from '../../ioc-extras';
import { ExtensionContext } from '../../ioc-extras';
import { INvmResolver } from '../../targets/node/nvmResolver';
import { fixInspectFlags } from '../configurationUtils';
import { resolveProcessId } from '../processPicker';
import { BaseConfigurationResolver } from './baseConfigurationResolver';
import { LocalFsUtils } from '../../common/fsUtils';
import { FSUtils, LocalFsUtils } from '../../common/fsUtils';

const localize = nls.loadMessageBundle();

Expand Down

0 comments on commit 0c8afe0

Please sign in to comment.