microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
565e75ea9338b2607cf546d95b0e36913075068f

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/reactDirManager.ts

33lines · 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 {ErrorHelper} from "../common/error/errorHelper";
8import {InternalErrorCode} from "../common/error/internalErrorCode";
9import {FileSystem} from "../common/node/fileSystem";
10import {EntryPointHandler} from "../common/entryPointHandler";
11
12/**
13 * Manages the lifecycle of the .vscode/.react folder, which hosts the temporary source/map files we need for debugging.
14 * We use synchronous operations here because we want to return after the init/cleanup has been done.
15 */
16export class ReactDirManager implements vscode.Disposable {
17 public static ReactDirPath = path.join(vscode.workspace.rootPath, ".vscode", ".react");
18
19 public create(): Q.Promise<void> {
20 let fs = new FileSystem();
21 /* if the folder exists, remove it, then recreate it */
22 return fs.removePathRecursivelyAsync(ReactDirManager.ReactDirPath)
23 .then(() =>
24 fs.mkDir(ReactDirManager.ReactDirPath));
25 }
26
27 public dispose(): void {
28 new EntryPointHandler(vscode.window.createOutputChannel("React-Native")).runFunction("extension.deleteTemporaryFolder",
29 ErrorHelper.getInternalError(InternalErrorCode.RNTempFolderDeletionFailed, ReactDirManager.ReactDirPath),
30 () =>
31 new FileSystem().removePathRecursivelySync(ReactDirManager.ReactDirPath));
32 }
33}