Created
January 8, 2020 20:38
-
-
Save bfitzpat/847e45f2a59a398b7a99fe2451cd3da2 to your computer and use it in GitHub Desktop.
getCurrentFolder v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getCurrentFolder(): Promise<string> { | |
| return new Promise(async (resolve, reject) => { | |
| await vscode.commands.executeCommand('workbench.view.explorer').then( async () => { | |
| await vscode.commands.executeCommand('copyFilePath').then(async () => { | |
| try { | |
| await vscode.env.clipboard.readText().then((copyPath) => { | |
| try { | |
| if (fs.existsSync(copyPath)) { | |
| resolve(copyPath); | |
| return copyPath; | |
| } | |
| } catch (err) { | |
| reject(err); | |
| return undefined; | |
| } | |
| }); | |
| } catch (err) { | |
| reject(err); | |
| return undefined; | |
| } | |
| }); | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment