microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
4b124a08cf4726fc4b6b1f843dcd24e31f33db5e

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/reactDirManager.ts

34lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import * as Q from "q";
5import * as vscode from "vscode";
6import * as path from "path";
7import {OutputChannelLogger} from "./outputChannelLogger";
8import {ErrorHelper} from "../common/error/errorHelper";
9import {InternalErrorCode} from "../common/error/internalErrorCode";
10import {FileSystem} from "../common/node/fileSystem";
11import {EntryPointHandler, ProcessType} from "../common/entryPointHandler";
12
13/**
14 * Manages the lifecycle of the .vscode/.react folder, which hosts the temporary source/map files we need for debugging.
15 * We use synchronous operations here because we want to return after the init/cleanup has been done.
16 */
17export class ReactDirManager implements vscode.Disposable {
18 public static ReactDirPath = path.join(vscode.workspace.rootPath, ".vscode", ".react");
19
20 public setup(): Q.Promise<void> {
21 let fs = new FileSystem();
22 /* if the folder exists, remove it, then recreate it */
23 return fs.removePathRecursivelyAsync(ReactDirManager.ReactDirPath)
24 .then(() =>
25 fs.mkDir(ReactDirManager.ReactDirPath));
26 }
27
28 public dispose(): void {
29 new EntryPointHandler(ProcessType.Extension, new OutputChannelLogger(vscode.window.createOutputChannel("React-Native"))).runFunction("extension.deleteTemporaryFolder",
30 ErrorHelper.getInternalError(InternalErrorCode.RNTempFolderDeletionFailed, ReactDirManager.ReactDirPath),
31 () =>
32 new FileSystem().removePathRecursivelySync(ReactDirManager.ReactDirPath));
33 }
34}
35