microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
cc7d2e1bd7c2985d11d65ac2268248b4e9fcbc2f

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/reactDirManager.ts

40lines · 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";
18d8ad2adigeff10 years ago11import {EntryPointHandler, ProcessType} 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 {
cc7d2e1bJimmy Thomson9 years ago18public static VscodeDirPath = path.join(vscode.workspace.rootPath || "", ".vscode");
19public static ReactDirPath = path.join(ReactDirManager.VscodeDirPath, ".react");
b3a793eeNisheet Jain10 years ago20
710f8655digeff10 years ago21public setup(): Q.Promise<void> {
b3a793eeNisheet Jain10 years ago22let fs = new FileSystem();
23/* if the folder exists, remove it, then recreate it */
10873e11digeff10 years ago24return fs.removePathRecursivelyAsync(ReactDirManager.ReactDirPath)
cc7d2e1bJimmy Thomson9 years ago25.then(() => {
26if (!fs.existsSync(ReactDirManager.VscodeDirPath)) {
27return fs.mkDir(ReactDirManager.VscodeDirPath);
28}
29}).then(() =>
30fs.mkDir(ReactDirManager.ReactDirPath)
31);
b3a793eeNisheet Jain10 years ago32}
33
34public dispose(): void {
18d8ad2adigeff10 years ago35new EntryPointHandler(ProcessType.Extension, new OutputChannelLogger(vscode.window.createOutputChannel("React-Native"))).runFunction("extension.deleteTemporaryFolder",
c2bf3c4fdigeff10 years ago36ErrorHelper.getInternalError(InternalErrorCode.RNTempFolderDeletionFailed, ReactDirManager.ReactDirPath),
10873e11digeff10 years ago37() =>
ef24cc06digeff10 years ago38new FileSystem().removePathRecursivelySync(ReactDirManager.ReactDirPath));
b3a793eeNisheet Jain10 years ago39}
40}