How to use the rmdir function from fs

Find comprehensive JavaScript fs.rmdir code examples handpicked from public code repositorys.

24
25
26
27
28
29
30
31
32
33
* fs.readdir(): 读取目录的内容。
* fs.readFile(): 读取文件的内容。相关方法:fs.read()。
* fs.readlink(): 读取符号链接的值。
* fs.realpath(): 将相对的文件路径指针(.、..)解析为完整的路径。
* fs.rename(): 重命名文件或文件夹。
* fs.rmdir(): 删除文件夹。
* fs.stat(): 返回文件(通过传入的文件名指定)的状态。相关方法:fs.fstat()、fs.lstat()。
* fs.symlink(): 新建文件的符号链接。
* fs.truncate(): 将传递的文件名标识的文件截断为指定的长度。相关方法:fs.ftruncate()。
* fs.unlink(): 删除文件或符号链接。
fork icon192
star icon570
watch icon16

+ 5 other calls in file

387
388
389
390
391
392
393
394
395
396
    assert.strictEqual(err.code, 'ENOENT');
  }
  return true;
};

fs.rmdir(existingFile, common.mustCall(validateError));

assert.throws(
  () => fs.rmdirSync(existingFile),
  validateError
fork icon42
star icon19
watch icon0

+ 3 other calls in file

172
173
174
175
176
177
178
179
180
181
console.log('Connection closed. You are logged out.')
clearInterval(intervalStore[token])
delete sock[token]
delete qrcode[token]
io.emit('message', {token: token, message: 'Connection closed. You are logged out.'})
fs.rmdir(`credentials/${token}`, { recursive: true }, (err) => {
    if (err) {
        throw err;
    }
    console.log(`credentials/${token} is deleted`);
fork icon1
star icon3
watch icon1

+ 5 other calls in file

597
598
599
600
601
602
603
604
605
  // tricky windows absolute path with UNC or 8.3 parts (and
  // preservePaths:true, or else it will have been stripped).
  // In that case, the user has opted out of path protections
  // explicitly, so if they blow away the cwd, c'est la vie.
  if (entry.absolute !== this.cwd) {
    return fs.rmdir(entry.absolute, er =>
      this[MAKEFS](er, entry, done))
  }
}
fork icon3
star icon2
watch icon0

722
723
724
725
726
727
728
729
730
731

const entryPath = `${dirPath}/${entryName}`;
const entryStat = await fs.stat(entryPath);
if (entryStat.isDirectory()) {
    await removeDir(entryPath);
    await fs.rmdir(entryPath);
}
else if (entryStat.isFile()) {
    await fs.unlink(entryPath);
}
fork icon0
star icon1
watch icon1

155
156
157
158
159
160
161
162
163
164
165
166
}


function mkdir() {
  const fs = require('fs');
  fs.mkdir('fstemp0', () => {
    fs.rmdir('fstemp0', () => {});
  });
}


function mktmp() {
fork icon0
star icon0
watch icon0

+ 8 other calls in file

577
578
579
580
581
582
583
584
585
586
{
  let projectID = body.data.data[0].id;
  // Delete project
  this.api.delete('/projects/' + projectID).then(body =>
  {
    fs.rmdir(`${this.projectsDir}/${projectName}`, { recursive: true }, (err) =>
    {
      if (err)
      {
        return res.json({
fork icon0
star icon0
watch icon0