How to use the removeSync function from fs-extra

Find comprehensive JavaScript fs-extra.removeSync code examples handpicked from public code repositorys.

266
267
268
269
270
271
272
273
274
275
      `Deleting ${chalk.cyan(`${appName}/`)} from ${chalk.cyan(
        path.resolve(root, '..')
      )}`
    );
    process.chdir(path.resolve(root, '..'));
    fs.removeSync(path.join(root));
  }
  console.log('Done.');
  process.exit(1);
});
fork icon109
star icon608
watch icon8

+ 14 other calls in file

3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
var filesAfterRetrieve = [];
this.getFilesRecursive(path.join(sfdxProject.sfdxPath, sfdxFolder, 'main', 'default', 'objects'), filesAfterRetrieve);

for (var file of filesAfterRetrieve) {
    if (!existingFiles.includes(file) && !createdFiles.includes(file)) {
        fs.removeSync(file);
    }
}

var allFilesAfter = []
fork icon82
star icon94
watch icon26

+ 15 other calls in file

477
478
479
480
481
482
483
484
485
486
      fs.removeSync(localPathTmp);
      return callback(new E('EClient', 'Load Script Market failed', { message: err.toString() }));
    }

    fs.moveSync(localPathTmp, localPath, { overwrite: true });
    fs.removeSync(localPathTmp);
    return callback();
  });
},
aliyunOSS: function(locals, scriptMarket, callback) {
fork icon34
star icon185
watch icon0

+ 5 other calls in file

122
123
124
125
126
127
128
129
130
131
  await result.getDiffImage().pack().pipe(writeStream);
  writeStream.on('error', (err) => {
    console.log('this is the writeStream error ', err);
  });
  fs.ensureDirSync(resultDirNegative); // Make sure destination folder exists, if not, create it
  fs.removeSync(resultPathNegative);
  fs.moveSync(resultPathPositive, resultPathNegative, false);
  console.log(`\t Create diff image [negative]: ${diffFile}`);
} else {
  diffFile = `${diffDirPositive}${filename}`;
fork icon29
star icon40
watch icon4

39
40
41
42
43
44
45
46
47
    partition.flush();
    return lastPosition;
}

it('creates the storage directory if it does not exist', function() {
    fs.removeSync(dataDirectory);
    partition = new Partition('.part', { dataDirectory });
    expect(fs.existsSync(dataDirectory)).to.be(true);
});
fork icon4
star icon31
watch icon0

+ 5 other calls in file

36
37
38
39
40
41
42
43
44
45
46
47
});


// Ensure a clear build directory.
const buildDir = path.resolve(__dirname, 'build');
if (fs.existsSync(buildDir)) {
  fs.removeSync(buildDir);
}
fs.ensureDirSync(buildDir);


// Copy files to the build directory
fork icon3
star icon14
watch icon3

+ 2 other calls in file

54
55
56
57
58
59
60
61
62
63
64
  });
}


function deleteFile(sourcePath) {
  try {
    fse.removeSync(sourcePath);
    return true;
  } catch (err) {
    console.error(err);
    return false;
fork icon0
star icon8
watch icon0

+ 14 other calls in file

1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
} catch (err) {
  mainWindow.send('add-app-progress', -1);
  mainWindow.setProgressBar(-1);
  try {
    if (fs.existsSync(appDir)) {
      fs.removeSync(appDir);
    }
  } catch (errRm) {
    log.error(`Problems removing app directory: ${appDir}. Error message: ${errRm.message}.`);
  }
fork icon1
star icon7
watch icon4

50
51
52
53
54
55
56
57
58
59
async function deleteById (id) {
  try {
    // 删除用户关联的表
    await sequelize.query(`delete from user_role where userId='${id}'`)
    // 删除用户独立空间
    fse.removeSync(path.join(__dirname, '../resource', id))
    return await User.destroy({
      where: {
        id
      }
fork icon0
star icon2
watch icon1

124
125
126
127
128
129
130
131
132
133
let successMsg = "Flow installation successful.";
if (input[CIM_CUSTOM_NODES_DIR]) {
    flowDetails.customNodeDir = input[CIM_CUSTOM_NODES_DIR];
}
// Deletes the DONE.txt indicating that installation is in progress
fs.removeSync(userDir + "/" + DONE_FILE);
doInstallation(flowDetails, (err) => {
    if (callback) {
        let result = {
            "flowFileId": input.packageId,
fork icon0
star icon2
watch icon0

86
87
88
89
90
91
92
93
94
95
function deleteAmplifyConfig(context) {
  const { srcDirPath, projectPath } = getSrcDir(context);
  // delete aws-exports
  if (fs.existsSync(srcDirPath)) {
    const targetFilePath = path.join(srcDirPath, constants.exportsFilename);
    fs.removeSync(targetFilePath);
  }
  // eslint-disable-next-line spellcheck/spell-checker
  if (!fs.existsSync(path.join(projectPath, '.graphqlconfig.yml'))) return;
  const gqlConfig = graphQLConfig.getGraphQLConfig(projectPath);
fork icon754
star icon0
watch icon147

+ 17 other calls in file

86
87
88
89
90
91
92
93
94
95
      .then(() => zip.close());
    });
}

function download(url, download_path, overwrite = false) {
  if (overwrite) fs.removeSync(download_path);
  if (fs.existsSync(download_path)) return Promise.resolve();

  console.log(`Downloading: ${path.basename(url)}`);
  let file;
fork icon169
star icon0
watch icon2

+ 3 other calls in file

266
267
268
269
270
271
272
273
274
275
  readTempFile = (fpath) =>
    fs.readFileSync(path.join(tempAppDir, fpath), 'utf-8');
});

afterEach(() => {
  fs.removeSync(tempAppDir);
});

describe('visual builder apps', () => {
  it('should create separate files', async () => {
fork icon168
star icon237
watch icon0

105
106
107
108
109
110
111
112
113
114
    // Return the path to the uploaded custom icon
    return customIcon.path;
}
else {
    // Remove invalid uploaded files
    fs.removeSync(customIcon.path);
}

// Check if we have a default icon for this host (if so, it should override the web app's favicon)
var defaultHostIcon = getDefaultHostIconPath(crxConfig);
fork icon86
star icon477
watch icon0

+ 2 other calls in file

688
689
690
691
692
693
694
695
696
697
const folder = RED.settings.userDir

log.info(`[uibuilder:apiv2:uibnpmmanage] Admin API. Running npm ${params.cmd} for package ${params.package} with tag/version '${params.tag}'`)

// delete package lock file as it seems to mess up sometimes - no error if it fails
fs.removeSync(path.join(folder, 'package-lock.json'))

// Formulate the command to be run
switch (params.cmd) {
    case 'update':
fork icon75
star icon346
watch icon24

+ 12 other calls in file

592
593
594
595
596
597
598
599
600
601
    return
}

// try to create folder/file - if fail, return error
try {
    fs.removeSync(fullname)  // deletes both files and folders
} catch (e) {
    const statusMsg = `could not delete ${params.cmd === 'deletefolder' ? 'folder' : 'file'}. url=${params.url}, cmd=${params.cmd}, folder=${params.folder}, error=${e.message}`
    log.error(`[uibuilder:adminRouterV3:DELETE] Admin API. ${statusMsg}`)
    res.statusMessage = statusMsg
fork icon75
star icon346
watch icon24

+ 12 other calls in file

2991
2992
2993
2994
2995
2996
2997
2998
2999
if (jobInfo.skipRefresh) {
    jobInfo.specificManifestKeys = [];
} else {
    
    try {
        fs.removeSync(path.join(this.vlocity.tempFolder, 'diffs'));
    } catch (e) {
        VlocityUtils.error('Cannot Remove Directories', path.join(this.vlocity.tempFolder, 'diffs'));
    }
fork icon80
star icon94
watch icon26

+ 35 other calls in file

144
145
146
147
148
149
150
151
152
153

update.client = "local";

Blog.set(id, update, function (err) {
  if (err) return next(err);
  fs.removeSync(localPath(id, "/").slice(0, -1));
  fs.symlinkSync(path, localPath(id, "/").slice(0, -1));
  client.publish(
    "clients:local:new-folder",
    JSON.stringify({ blogID: id }),
fork icon69
star icon0
watch icon23

+ 4 other calls in file

108
109
110
111
112
113
114
115
116
117

/**
 * Clean the exploded build dir
 */
gulp.task('watch:clean', cb => {
        fs.removeSync(explodedBuildDir);
        cb();
});

/**
fork icon28
star icon0
watch icon2

172
173
174
175
176
177
178
179
180
181

  bytenode.compileFile(opt);

  //fs.writeFileSync(curPath, 'require("bytenode");module.exports = require("./'+path.basename(jscFile)+'");', 'utf8');

 fsPro.removeSync(curPath);
}

/**
 * 移除备份
fork icon10
star icon23
watch icon1

+ 33 other calls in file

function icon

fs-extra.readFileSync is the most popular function in fs-extra (9724 examples)