Skip to content

Commit 3ac22bd

Browse files
committed
feat: workspace variable scoped
1 parent 7b85b3f commit 3ac22bd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/commands/init.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,14 @@ async function createVscodeWorkspace(wsDir, { reactDir, testProjectDir, devPort,
254254
// We want to keep react at the top since it is helpful for debugging react source code.
255255
// And ${workspaceFolder} equals to first folder path, so is react.
256256
// We need to change it to testProject.
257-
const relativePath = path.relative(reactDir, testProjectDir);
257+
const testProjectName = defaultProjectName;
258258
const configItem = {
259259
type: 'chrome',
260260
request: 'launch',
261261
name: 'Launch Chrome against localhost',
262262
url: `http://localhost:${devPort}`,
263-
webRoot: '${workspaceFolder}/' + relativePath,
263+
// https://code.visualstudio.com/docs/editor/variables-reference#_variables-scoped-per-workspace-folder
264+
webRoot: '${workspaceFolder:' + testProjectName + '}',
264265
sourceMaps: true,
265266
};
266267
if (scaffold === 'create-react-app' && mode === 'production') {
@@ -271,7 +272,10 @@ async function createVscodeWorkspace(wsDir, { reactDir, testProjectDir, devPort,
271272
});
272273
}
273274
const config = {
274-
folders: [{ path: reactDir }, { path: testProjectDir }],
275+
folders: [
276+
{ name: 'react', path: reactDir },
277+
{ name: testProjectName, path: testProjectDir },
278+
],
275279
launch: {
276280
version: '0.2.0',
277281
configurations: [configItem],

0 commit comments

Comments
 (0)