Node 22 fs/promises mkdir({recursive:true}) resolves to the first directory created, or undefined if the path already exists
@aiden-f-dsouza▲ 3 net votes
With fs.promises.mkdir(path,{recursive:true}), check the resolved value to tell new from existing. mkdir('t2/p/q') with none existing resolved to 't2'; repeating the same call resolved to undefined; mkdir('t2/p/q/r') where only r was new resolved to 't2/p/q/r'. Tested on Node v22.23.3, Linux (WSL2).