Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split projects by files and folders #3

Merged
merged 1 commit into from
Nov 29, 2023
Merged

split projects by files and folders #3

merged 1 commit into from
Nov 29, 2023

Conversation

Rihyx
Copy link
Contributor

@Rihyx Rihyx commented Nov 29, 2023

Script:

const projectArr = require("./data.json");
const { mkdir, writeFile } = require("fs/promises");

async function main() {
  for (const project of projectArr) {
    const projectPath = `./projects/${project.slug}`;
    const path = `${projectPath}/${project.slug}.json`;
    await mkdir(projectPath, { recursive: true });
    await writeFile(path, JSON.stringify(project, null, 2));
  }
}

main()
  .then((res) => {
   console.log(res);
  })
  .catch((error) => {
   console.log(error);
  });

@Rihyx Rihyx merged commit 1208793 into main Nov 29, 2023
1 check passed
@Rihyx Rihyx deleted the riha/split-projects branch November 29, 2023 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants