microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.1.4

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/reactDirManager.ts

34lines · modeblame

b3a793eeNisheet Jain10 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
10873e11digeff10 years ago4import * as Q from "q";
b3a793eeNisheet Jain10 years ago5import * as vscode from "vscode";
6import * as path from "path";
c2bf3c4fdigeff10 years ago7import {OutputChannelLogger} from "./outputChannelLogger";
8import {ErrorHelper} from "../common/error/errorHelper";
9import {InternalErrorCode} from "../common/error/internalErrorCode";
10873e11digeff10 years ago10import {FileSystem} from "../common/node/fileSystem";
47958817digeff10 years ago11import {EntryPointHandler} from "../common/entryPointHandler";
b3a793eeNisheet Jain10 years ago12
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 {
18public static ReactDirPath = path.join(vscode.workspace.rootPath, ".vscode", ".react");
19
710f8655digeff10 years ago20public setup(): Q.Promise<void> {
b3a793eeNisheet Jain10 years ago21let fs = new FileSystem();
22/* if the folder exists, remove it, then recreate it */
10873e11digeff10 years ago23return fs.removePathRecursivelyAsync(ReactDirManager.ReactDirPath)
24.then(() =>
25fs.mkDir(ReactDirManager.ReactDirPath));
b3a793eeNisheet Jain10 years ago26}
27
28public dispose(): void {
c2bf3c4fdigeff10 years ago29new EntryPointHandler(false, new OutputChannelLogger(vscode.window.createOutputChannel("React-Native"))).runFunction("extension.deleteTemporaryFolder",
30ErrorHelper.getInternalError(InternalErrorCode.RNTempFolderDeletionFailed, ReactDirManager.ReactDirPath),
10873e11digeff10 years ago31() =>
ef24cc06digeff10 years ago32new FileSystem().removePathRecursivelySync(ReactDirManager.ReactDirPath));
b3a793eeNisheet Jain10 years ago33}
34}