MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / writeSettingIntoProject

Function writeSettingIntoProject

src/shared/utils/projects.ts:20–36  ·  view source on GitHub ↗
(projectFolder: string, settings: any)

Source from the content-addressed store, hash-verified

18}
19
20function writeSettingIntoProject(projectFolder: string, settings: any): void {
21 const vsCodeFolder = path.join(projectFolder, ".vscode");
22 const settingsFile = path.join(vsCodeFolder, "settings.json");
23
24 if (!fs.existsSync(vsCodeFolder))
25 fs.mkdirSync(vsCodeFolder);
26
27 // The file should never exist, because the user has to select a new folder
28 // to create projects. If it exists, something is wrong. We can't just load
29 // the file, because VS Code settings file are not standard JSON (they can
30 // have comments) so we don't want to try and deal with parsing them.
31 if (fs.existsSync(settingsFile))
32 return;
33
34 fs.writeFileSync(settingsFile, JSON.stringify(settings, undefined, 4));
35
36}

Calls

no outgoing calls

Tested by

no test coverage detected