tis-cli前端项目快速搭建命令行工具
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
545 B

4 years ago
  1. 'use strict'
  2. const fs = require('../fs')
  3. const { checkPath } = require('./utils')
  4. const getMode = options => {
  5. const defaults = { mode: 0o777 }
  6. if (typeof options === 'number') return options
  7. return ({ ...defaults, ...options }).mode
  8. }
  9. module.exports.makeDir = async (dir, options) => {
  10. checkPath(dir)
  11. return fs.mkdir(dir, {
  12. mode: getMode(options),
  13. recursive: true
  14. })
  15. }
  16. module.exports.makeDirSync = (dir, options) => {
  17. checkPath(dir)
  18. return fs.mkdirSync(dir, {
  19. mode: getMode(options),
  20. recursive: true
  21. })
  22. }