How to use the copyAsync function from fs-extra

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

190
191
192
193
194
195
196
197
198
199

// Create a new destination directory.
prepTasks.push(
  fs.mkdirsAsync(this.options.destination).then(() => {
    // Optionally, copy the contents of the builder's "kss-assets" folder.
    return fs.copyAsync(
      path.join(this.options.builder, 'kss-assets'),
      path.join(this.options.destination, 'kss-assets'),
      {
        clobber: true,
fork icon293
star icon1
watch icon2

42
43
44
45
46
47
48
49
50
51
    // Remove existing sketch folder if it exists
    return fs.removeAsync(stagedSketchDir)
        .then(function()
        {
            // Copy the sketch folder to the staging sketch dir
            return fs.copyAsync(options.sketchDir, stagedSketchDir);
        });
})
.then(function()
{
fork icon94
star icon63
watch icon33

+ 4 other calls in file

90
91
92
93
94
95
96
97
98
99
};

// copy generated handler so we can build directly from the source directory
const generatedHandler = path.join(webpackConfig.context, handlerFileName);

return fs.copyAsync(path.join(pathDist, handlerFileName), generatedHandler)
  .then(() => fs.mkdirsAsync(optimizedModulesPath))
  .then(() => runWebpack(webpackConfig))
  .then((stats) => {
    logStats(stats);
fork icon28
star icon68
watch icon12

+ 3 other calls in file

235
236
237
238
239
240
241
    });
} else if (ext == '.so') {
  var src = path.join(baseDir, filePath);
  var basename = path.basename(filePath);
  return Promise.all([
    fs.copyAsync(src, path.join(outputPath, 'libs', 'armeabi', basename)),
    fs.copyAsync(src, path.join(outputPath, 'libs', 'armeabi-v7a', basename))
fork icon22
star icon14
watch icon49

+ 3 other calls in file

53
54
55
56
57
58
59
60
61
62
    logger.info('Uninstall complete.');
  });
};
function InstallFile(baseDir, file) {
  var src = path.resolve(path.join(baseDir, 'files', file.src));
  return fs.copyAsync(src, path.join(file.dest, path.basename(file.src)));
}
function UninstallFile(file) {
  return fs.removeAsync(path.join(file.dest, path.basename(file.src)));
}
fork icon94
star icon63
watch icon33

167
168
169
170
171
172
173
174
175
176
return this.wrap(wrapperDir, wrapperPy, this.libSubDir, target.realHandler).bind(this)
  .then(_.partial(this.fileAccessable, Path.join(wrapperDir, 'requirements.txt'))).bind(this)
  .then(_.partial(this.hard_remove, [wrapperPy, packagePath]))
  .then(() => { return Fse.ensureDirAsync(packagePath); })
  .then(() => {
    return Fse.copyAsync(
      Path.join(__dirname, 'requirements.py'), requirementsPy);
  }).bind(this)
  .then(_.partial(this.preinstall, wrapperDir, this.libSubDir, runtime)).bind(this)
  .then(_.partial(this.install, wrapperDir, this.libSubDir, runtime)).bind(this)
fork icon16
star icon25
watch icon3

44
45
46
47
48
49
50
51
52
53
messageToSend.transactionId = new mongoose.Types.ObjectId();
messageToSend.startTime = startTime;
messageToSend.endTime = endTime;
fs.mkdirsAsync(fullPath)
        .then(function() {
                return fs.copyAsync(HARDCODED_FILE_PATH, path.join(fullPath, fileName));
        })
        .then(function() {
                messageToSend.fileRelativePath = path.join(pathBuilder(startTime, SOURCE_ID), fileName);
                return rabbit.produce('TransportStreamProcessingQueue', messageToSend);
fork icon10
star icon7
watch icon26

39
40
41
42
43
44
45
46
47
48
await fs.ensureFile(join(cwd, dir, 'db', 'development.sqlite3'));
await fs.ensureFile(join(cwd, dir, 'db', 'test.sqlite3'));
await fs.ensureFile(join(cwd, dir, 'db', 'production.sqlite3'));

// static files
await fs.copyAsync(themeDir, join(cwd, dir));

const isYarnInstalled = await hasbin('yarn');

if (isYarnInstalled) {
fork icon36
star icon0
watch icon2

150
151
152
153
154
155
156
157
158
  if (!copiedImages.includes(to)) {
    logger.warn(
      `References to local images will not work in production. Please copy ${src} to a server.`
    )
    copiedImages.push(to)
    return fse.copyAsync(from, to)
  }
  return Promise.resolve()
}
fork icon1
star icon16
watch icon9

66
67
68
69
70
71
72
73
74
75

function copyHook(hook, targetDir) {
  var hookPath = getHookPath(hook),
      hookTargetPath = path.join(targetDir, path.basename(hookPath));

  return fsExtra.copyAsync(hookPath, hookTargetPath)
    .then(function() {
      if (helpers.isWin) {
        return fsExtra.copyAsync(hookPath + '.bat', hookTargetPath + '.bat')
          .then(function() {
fork icon0
star icon2
watch icon2

+ 3 other calls in file

45
46
47
48
49
50
51
52
53
54
    set(this.serverless.service, ['package', 'include'], []);
  }

  this.serverless.service.package.include.push('unzip_requirements.py');

  return fse.copyAsync(
    path.resolve(__dirname, '../unzip_requirements.py'),
    path.join(this.servicePath, 'unzip_requirements.py')
  );
}
fork icon274
star icon0
watch icon14

+ 3 other calls in file

90
91
92
93
94
95
96
97
98
99
/**
 * Install mode
 */
if (err.code === 'ENOENT') {
  ora.text = 'First-time install, creating a new config.yml...'
  return fs.copyAsync(path.join(installDir, 'config.sample.yml'), path.join(installDir, 'config.yml')).then(() => {
    ora.succeed('Installation succeeded. You can now continue with the configuration steps. Check out https://docs.wiki.requarks.io/install for more info.')
  })
} else {
  return err
fork icon0
star icon0
watch icon2

function icon

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