Created
September 5, 2022 11:09
-
-
Save tjunghans/01fb1335b7919847d1323dfdc3e9bc58 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env node | |
const { readdir, writeFile } = require("fs"); | |
const { promisify } = require("util"); | |
function createDirEntry(dir) { | |
return { name: dir, path: `packages/node_modules/${dir}` }; | |
} | |
function createProjectCodeWorkspaceContents(dirs) { | |
return JSON.stringify( | |
{ | |
folders: [ | |
{ | |
path: ".", | |
}, | |
...dirs.map((dir) => createDirEntry(dir)), | |
], | |
}, | |
null, | |
2 | |
); | |
} | |
async function main() { | |
const dirs = await promisify(readdir)("./packages/node_modules"); | |
const result = createProjectCodeWorkspaceContents(dirs); | |
writeFile("./project.code-workspace", result, (err, res) => { | |
if (err) { | |
console.log(err); | |
process.exit(1); | |
} | |
console.log("Success"); | |
}); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment