microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
f5edf87f2af14e37e63c6f6638d9558fc6a5d1ee

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/reactDirManager.ts

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