Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d6b5b5

Browse files
committed
fix workspaceRoot deprecation warnings
1 parent74159d5 commit0d6b5b5

File tree

8 files changed

+32
-87
lines changed

8 files changed

+32
-87
lines changed

‎src/actions/setupActions.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const runCommands = async (commands: string[], language: string) => {
3636
}
3737

3838

39-
constsetupActions=async({commands, commits, files}:G.StepActions):Promise<void>=>{
39+
constsetupActions=async(workspaceRoot:vscode.WorkspaceFolder,{commands, commits, files}:G.StepActions):Promise<void>=>{
4040
// run commits
4141
for(constcommitofcommits){
4242
awaitgit.loadCommit(commit)
@@ -49,18 +49,7 @@ const setupActions = async ({commands, commits, files}: G.StepActions): Promise<
4949
for(constfilePathoffiles){
5050
console.log(`OPEN_FILE${filePath}`)
5151
try{
52-
// TODO: re-enable after testing
53-
// const workspaceRoots: vscode.WorkspaceFolder[] | undefined = vscode.workspace.workspaceFolders
54-
// if (!workspaceRoots || !workspaceRoots.length) {
55-
// throw new Error('No workspace root path')
56-
// }
57-
// const rootWorkspace: vscode.WorkspaceFolder = workspaceRoots[0]
58-
// const absoluteFilePath = join(rootWorkspace.uri.path, relativeFilePath)
59-
constworkspaceRoot=vscode.workspace.rootPath
60-
if(!workspaceRoot){
61-
thrownewError('No workspace root path')
62-
}
63-
constabsoluteFilePath=join(workspaceRoot,filePath)
52+
constabsoluteFilePath=join(workspaceRoot.uri.path,filePath)
6453
constdoc=awaitvscode.workspace.openTextDocument(absoluteFilePath)
6554
awaitvscode.window.showTextDocument(doc,vscode.ViewColumn.One)
6655
// there are times when initialization leave the panel behind any files opened

‎src/channel/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ interface Channel {
1717
interfaceChannelProps{
1818
postMessage:(action:CR.Action)=>Thenable<boolean>
1919
workspaceState:vscode.Memento
20+
workspaceRoot:vscode.WorkspaceFolder
2021
}
2122

2223

2324
classChannelimplementsChannel{
2425
privatepostMessage:(action:CR.Action)=>Thenable<boolean>
2526
privateworkspaceState:vscode.Memento
27+
privateworkspaceRoot:vscode.WorkspaceFolder
2628
privatecontext:Context
27-
constructor({postMessage, workspaceState}:ChannelProps){
29+
constructor({postMessage, workspaceState, workspaceRoot}:ChannelProps){
2830
// workspaceState used for local storage
2931
this.workspaceState=workspaceState
32+
this.workspaceRoot=workspaceRoot
3033
this.postMessage=postMessage
3134
this.context=newContext(workspaceState)
3235
}
@@ -96,7 +99,7 @@ class Channel implements Channel {
9699
// load step actions (git commits, commands, open files)
97100
case'SETUP_ACTIONS':
98101
vscode.commands.executeCommand('coderoad.set_current_step',action.payload)
99-
setupActions(action.payload)
102+
setupActions(this.workspaceRoot,action.payload)
100103
return
101104
// load solution step actions (git commits, commands, open files)
102105
case'SOLUTION_ACTIONS':

‎src/editor/ReactWebView.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const getNonce = (): string => {
1616
interfaceReactWebViewProps{
1717
extensionPath:string
1818
workspaceState:vscode.Memento
19+
workspaceRoot:vscode.WorkspaceFolder
1920
}
2021

2122

@@ -30,7 +31,7 @@ class ReactWebView {
3031
privatedisposables:vscode.Disposable[]=[]
3132
privatechannel:Channel
3233

33-
publicconstructor({extensionPath, workspaceState}:ReactWebViewProps){
34+
publicconstructor({extensionPath, workspaceState, workspaceRoot}:ReactWebViewProps){
3435
this.extensionPath=extensionPath
3536

3637
// Create and show a new webview panel
@@ -71,6 +72,7 @@ class ReactWebView {
7172
// channel connects webview to the editor
7273
this.channel=newChannel({
7374
workspaceState,
75+
workspaceRoot,
7476
postMessage:(action:Action):Thenable<boolean>=>{
7577
// console.log(`postMessage ${JSON.stringify(action)}`)
7678
returnthis.panel.webview.postMessage(action)

‎src/editor/commands.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import*asvscodefrom'vscode'
22
importReactWebViewfrom'./ReactWebView'
33
importrunTestfrom'../actions/runTest'
4-
import{isEmptyWorkspace}from'./workspace'
54

65
constCOMMANDS={
76
START:'coderoad.start',
@@ -13,9 +12,10 @@ const COMMANDS = {
1312
interfaceCreateCommandProps{
1413
extensionPath:string
1514
workspaceState:vscode.Memento
15+
workspaceRoot:vscode.WorkspaceFolder
1616
}
1717

18-
exportconstcreateCommands=({extensionPath, workspaceState}:CreateCommandProps)=>{
18+
exportconstcreateCommands=({extensionPath, workspaceState, workspaceRoot}:CreateCommandProps)=>{
1919
// React panel webview
2020
letwebview:any
2121
letcurrentStepId=''
@@ -26,7 +26,7 @@ export const createCommands = ({extensionPath, workspaceState}: CreateCommandPro
2626
console.log('start')
2727

2828
// TODO: replace with a prompt to open a workspace
29-
awaitisEmptyWorkspace()
29+
//await isEmptyWorkspace()
3030

3131
letwebviewState:'INITIALIZING'|'RESTARTING'
3232
if(!webview){
@@ -43,6 +43,7 @@ export const createCommands = ({extensionPath, workspaceState}: CreateCommandPro
4343
webview=newReactWebView({
4444
extensionPath,
4545
workspaceState,
46+
workspaceRoot,
4647
})
4748
},
4849
// open React webview

‎src/editor/index.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@ class Editor {
66
//@ts-ignore
77
privatevscodeExt:vscode.ExtensionContext
88

9-
constructor(){
10-
// set workspace root for node executions
11-
constrootPath=vscode.workspace.rootPath
12-
if(!rootPath){
13-
thrownewError('Requires a workspace. Please open a folder')
14-
}
15-
}
169
publicactivate=(vscodeExt:vscode.ExtensionContext):void=>{
10+
1711
console.log('ACTIVATE!')
1812
this.vscodeExt=vscodeExt
1913

@@ -31,21 +25,19 @@ class Editor {
3125
}
3226

3327
privateactivateCommands=():void=>{
34-
// NOTE: local storage must be bound to the vscodeExt.workspaceState
3528

36-
// store current tutorial id & version
37-
38-
39-
// store step progress for current tutorial
40-
// const stepProgress = new Storage<{[stepId: string]: boolean}>({
41-
// key: 'coderoad:progress',
42-
// storage: this.vscodeExt.workspaceState,
43-
// defaultValue: {},
44-
// })
29+
// set workspace root for node executions
30+
constworkspaceRoots:vscode.WorkspaceFolder[]|undefined=vscode.workspace.workspaceFolders
31+
if(!workspaceRoots||!workspaceRoots.length){
32+
thrownewError('No workspace root path')
33+
}
34+
constworkspaceRoot:vscode.WorkspaceFolder=workspaceRoots[0]
4535

4636
constcommands=createCommands({
4737
extensionPath:this.vscodeExt.extensionPath,
38+
// NOTE: local storage must be bound to the vscodeExt.workspaceState
4839
workspaceState:this.vscodeExt.workspaceState,
40+
workspaceRoot,
4941
})
5042

5143
// register commands

‎src/editor/workspace.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎src/services/git/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import*asCRfrom'typings'
21
importnodefrom'../node'
32

43

‎src/services/node/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ import * as vscode from 'vscode'
77
constasyncExec=promisify(cpExec)
88

99
classNode{
10-
privateworkspaceRoot:string
10+
privateworkspaceRootPath:string
1111
constructor(){
12-
this.workspaceRoot=vscode.workspace.rootPath||''
13-
if(!this.workspaceRoot.length){
14-
thrownewError('Invalid workspaceRoot')
12+
// set workspace root for node executions
13+
constworkspaceRoots:vscode.WorkspaceFolder[]|undefined=vscode.workspace.workspaceFolders
14+
if(!workspaceRoots||!workspaceRoots.length){
15+
thrownewError('No workspace root path')
1516
}
16-
console.log(`workspaceRoot:${this.workspaceRoot}`)
17+
constworkspaceRoot:vscode.WorkspaceFolder=workspaceRoots[0]
18+
this.workspaceRootPath=workspaceRoot.uri.path
1719
}
1820
publicexec=(cmd:string):Promise<{stdout:string;stderr:string}>=>asyncExec(cmd,{
19-
cwd:this.workspaceRoot,
21+
cwd:this.workspaceRootPath,
2022
})
2123

22-
publicexists=(...paths:string[]):boolean=>fs.existsSync(join(this.workspaceRoot, ...paths))
24+
publicexists=(...paths:string[]):boolean=>fs.existsSync(join(this.workspaceRootPath, ...paths))
2325
}
2426

2527
exportdefaultnewNode()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp