| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b05cea5 commit e30d4c1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1053,6 +1053,34 @@ property indicating whether parent directories should be created. Calling | |||
| 1053 | 1053 | `fsPromises.mkdir()` when `path` is a directory that exists results in a | |
| 1054 | 1054 | rejection only when `recursive` is false. | |
| 1055 | 1055 | ||
| 1056 | + ```mjs | ||
| 1057 | + import { mkdir } from 'node:fs/promises'; | ||
| 1058 | + | ||
| 1059 | + try { | ||
| 1060 | + const projectFolder = new URL('./test/project/', import.meta.url); | ||
| 1061 | + const createDir = await mkdir(path, { recursive: true }); | ||
| 1062 | + | ||
| 1063 | + console.log(`created ${createDir}`); | ||
| 1064 | + } catch (err) { | ||
| 1065 | + console.error(err.message); | ||
| 1066 | + } | ||
| 1067 | + ``` | ||
| 1068 | + | ||
| 1069 | + ```cjs | ||
| 1070 | + const { mkdir } = require('node:fs/promises'); | ||
| 1071 | + const { resolve, join } = require('node:path'); | ||
| 1072 | + | ||
| 1073 | + async function makeDirectory() { | ||
| 1074 | + const projectFolder = join(__dirname, 'test', 'project'); | ||
| 1075 | + const dirCreation = await mkdir(projectFolder, { recursive: true }); | ||
| 1076 | + | ||
| 1077 | + console.log(dirCreation); | ||
| 1078 | + return dirCreation; | ||
| 1079 | + } | ||
| 1080 | + | ||
| 1081 | + makeDirectory().catch(console.error); | ||
| 1082 | + ``` | ||
| 1083 | + | ||
| 1056 | 1084 | ### `fsPromises.mkdtemp(prefix[, options])` | |
| 1057 | 1085 | ||
| 1058 | 1086 | <!-- YAML | |
| Back | FazBrowse Home | New Git URL |
0 commit comments