microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
8a67e140aee58da792b1e9c1c17358a98d5a3704

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/reactDirManager.ts

41lines · 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 VscodeDirPath = path.join(vscode.workspace.rootPath || "", ".vscode");
19 public static ReactDirPath = path.join(ReactDirManager.VscodeDirPath, ".react");
20
21 public setup(): Q.Promise<void> {
22 let fs = new FileSystem();
23 /* if the folder exists, remove it, then recreate it */
24 return fs.removePathRecursivelyAsync(ReactDirManager.ReactDirPath)
25 .then(() => {
26 if (!fs.existsSync(ReactDirManager.VscodeDirPath)) {
27 return fs.mkDir(ReactDirManager.VscodeDirPath);
28 }
29 return void 0;
30 }).then(() =>
31 fs.mkDir(ReactDirManager.ReactDirPath)
32 );
33 }
34
35 public dispose(): void {
36 new EntryPointHandler(ProcessType.Extension, new OutputChannelLogger(vscode.window.createOutputChannel("React-Native"))).runFunction("extension.deleteTemporaryFolder",
37 ErrorHelper.getInternalError(InternalErrorCode.RNTempFolderDeletionFailed, ReactDirManager.ReactDirPath),
38 () =>
39 new FileSystem().removePathRecursivelySync(ReactDirManager.ReactDirPath));
40 }
41}
42