microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/reactDirManager.ts
25lines · modeblame
b3a793eeNisheet Jain10 years ago | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. | |
| 3 | | |
9c9df666Meena Kunnathur Balakrishnan10 years ago | 4 | import {FileSystem} from "../common/node/fileSystem"; |
b3a793eeNisheet Jain10 years ago | 5 | import * as vscode from "vscode"; |
| 6 | import * as path from "path"; | |
| 7 | | |
| 8 | /** | |
| 9 | * Manages the lifecycle of the .vscode/.react folder, which hosts the temporary source/map files we need for debugging. | |
| 10 | * We use synchronous operations here because we want to return after the init/cleanup has been done. | |
| 11 | */ | |
| 12 | export class ReactDirManager implements vscode.Disposable { | |
| 13 | public static ReactDirPath = path.join(vscode.workspace.rootPath, ".vscode", ".react"); | |
| 14 | | |
| 15 | constructor() { | |
| 16 | let fs = new FileSystem(); | |
| 17 | /* if the folder exists, remove it, then recreate it */ | |
| 18 | fs.removePathRecursivelyAsync(ReactDirManager.ReactDirPath) | |
| 19 | .done(() => fs.mkDir(ReactDirManager.ReactDirPath)); | |
| 20 | } | |
| 21 | | |
| 22 | public dispose(): void { | |
| 23 | new FileSystem().removePathRecursivelySync(ReactDirManager.ReactDirPath); | |
| 24 | } | |
| 25 | } |