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

Is there a better way to create multiple directories using mkdir? #26993

Closed
FlandersBurger opened this issue Mar 29, 2019 · 1 comment
Closed

Comments

@FlandersBurger
Copy link

is there a better way to create a folder structure than nesting mkdirs?


          var dir = 'companies/' + newCompany.number;
          fs.mkdir(dir, function(err) {
            if (err) console.error(err);
            fs.mkdir(dir + '/pdfs', function(err) {
              if (err) console.error(err);
              fs.mkdir(dir + '/fonts', function(err) {
                if (err) console.error(err);
                fs.mkdir(dir + '/users', function(err) {
                  if (err) console.error(err);
                });
              });
            });
          });

@sam-github
Copy link
Contributor

Please post general questions on using node to nodejs/help.

There is a documented recursive option to mkdir: https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback

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

No branches or pull requests

2 participants