Example #1
0
gulp.task('copy', function() {
    fs.copy('cname', 'public/CNAME', function (err) {
        if (err) {
            return console.error(err);
        }
    });
    // fs.copy('index.html', 'public/index.html', function (err) {
    //     if (err) {
    //         return console.error(err);
    //     }
    // });
    // fs.copy('work.html', 'public/work.html', function (err) {
    //     if (err) {
    //         return console.error(err);
    //     }
    // });
    fs.mkdirs('public/fonts/', function (err) {
        if (err) {
            return console.error(err);
        }
    });
    fs.copy('fonts/', 'public/fonts/', function (err) {
        if (err) {
            return console.error(err);
        }
    });
    fs.mkdirs('public/vendor/js/', function (err) {
        if (err) {
            return console.error(err);
        }
    });
    fs.copy('js/', 'public/vendor/js/', function (err) {
        if (err) {
            return console.error(err);
        }
    });
    fs.copy('bower_components/jquery.stellar/jquery.stellar.min.js', 'public/vendor/js/jquery.stellar.min.js', function (err) {
        if (err) {
            return console.error(err);
        }
    });
    fs.copy('bower_components/jquery/dist/jquery.min.js', 'public/vendor/js/jquery.min.js', function (err) {
        if (err) {
            return console.error(err);
        }
    });

});
Example #2
0
			writeFile = function(filename, data){
				var code = data.code;
				var map = data.map;
				var check = function(){
					fileWrites--;
					if(fileWrites === 0) {
						finished();
					}
				};

				fileWrites++;
				fs.mkdirs(path.dirname(filename), function(err){
					if(err) {
						errors.push(err);
						check();
					} else {
						fs.writeFile(filename, code, function(err){
							if(err) {
								errors.push(err);
							}
							var sourceMaps = map && config.options &&
								config.options.sourceMaps;
							if(sourceMaps) {
								fs.writeFile(filename+".map", map+"", function(err){
									if(err) { errors.push(err); }
									check();
								});
								return;
							}
							check();
						});
					}
				});
			};
 .on("entry", function (entry) {
     var installpath = entry.path;
     if (prefixlength) {
         installpath = installpath.substring(prefixlength + 1);
     }
     
     if (entry.type === "Directory") {
         if (installpath === "") {
             return;
         }
         extractStream.pause();
         fs.mkdirs(installDirectory + "/" + installpath, function (err) {
             if (err) {
                 if (!callbackCalled) {
                     callback(err);
                     callbackCalled = true;
                 }
                 extractStream.close();
                 return;
             }
             extractStream.resume();
         });
     } else {
         entry.pipe(fs.createWriteStream(installDirectory + "/" + installpath))
             .on("error", function (err) {
                 if (!callbackCalled) {
                     callback(err);
                     callbackCalled = true;
                     readStream.destroy();
                 }
             });
     }
     
 })
Example #4
0
exports.cryptQueue = async.queue(function (file, callback) {
  fs.mkdirs(global.paths.crypted, function (err) {
    if (err) return callback(err)
    let parentPath = global.state.rfs[file.parents[0]].path
    // let parentPath = (_.has(file, parents)) ? global.state.rfs[file.parents[0]].path : file.parentPath
    // TODO: look into using path module
    let origpath = file.path
    let destpath = `${global.paths.crypted}/${file.name}.crypto`
    // logger.verbose(`TO ENCRYTPT: ${file.name} (${file.id}) at origpath: ${origpath} to destpath: ${destpath} with parentPath ${parentPath}`)
    crypto.encrypt(origpath, destpath, global.MasterPassKey.get(), function (err, key, iv, tag) {
      if (err) {
        return callback(err)
      } else {
        try {
          global.vault.files = global.vault.files || {}
          file.cryptPath = destpath
          file.iv = iv.toString('hex')
          file.authTag = tag.toString('hex')
          file.lastCrypted = moment().format()
          global.vault.files[file.id] = _.cloneDeep(file)
          global.vault.files[file.id].shares = crypto.pass2shares(key.toString('hex'))
          callback(null, file)
        } catch (err) {
          callback(err)
        }
      }
    })
  })
}, CONCURRENCY)
jsonfile.readFile(devPackage, (err, obj) => {
  if (err) {
    throw new Error(err)
  } else {
    jsonObj = {
      'name': obj.name,
      'productName': obj.build.productName,
      'version': obj.version,
      'description': obj.description,
      'author': obj.author,
      'private': true,
      'license': obj.license,
      'main': obj.main,
      'dependencies': obj.dependencies
    }
    fs.mkdirs(dstDir, () => {
      ncp(
        path.resolve(srcDir, 'main.js'),
        path.resolve(dstDir, 'main.js')
      )
      jsonfile.writeFile(appPackage, jsonObj, (err) => {
        if (err) {
          throw new Error(err)
        }
      })
    })
  }
})
Example #6
0
        }).then(function ( subtitles ) {
            // if we found a subtitle for this lang
            if (subtitles[lang] !== undefined) {

                var path = process.cwd() + '/.tmp/public/videos/' + torrent.id + '/';

                fs.mkdirs(path, function ( err ) {
                    if (err)
                        callback({ error: "Cant write subtitles on the disk.", log: err });
                    else {
                        // convert the subtitle
                         request(subtitles[lang].url)
                        .pipe(srt2vtt())
                        .pipe(fs.createWriteStream(path + "/" + lang + ".vtt"));

                        // register it into the db
                        Subtitle.create({ lang: lang, path: '/videos/' + torrent.id + "/" + lang + ".vtt", torrent: torrent }, function (err, model) {
                            if ( err )
                                callback({ error: "Cant save the subtitle into the database.", log: err });
                            else {
                                sails.log.debug("SubtitleService |  Subtitle in " + lang + " as been found and registered for torrent" + torrent.id);
						        callback(undefined, model.toJSON());
                            }
                        });
                    }
                })
            }
        }).catch(function ( err ) {
Example #7
0
    transform._transform = function (file, encoding, callback) {
        if (file.isNull()) {
            return callback();
        }

        if (file.isStream()) {
            this.emit('error', new PluginError('gulp-renderful',  'Streaming not supported'));
            return callback();
        }

        var viewpath = path.relative('./', file.path).replace('..' + path.sep),
            fullpath = path.join(filePath, viewpath),
            ext      = path.extname(file.path);

        fs.mkdirs(path.dirname(fullpath), function () {
            fs.writeFile(fullpath, file.contents, callback);
        });

        if (!opt.extensions.length || exts.indexOf(ext) !== -1) {
            registerExtension(ext);
        }

        file.viewpath = viewpath;
        files.push(file);
    }
Example #8
0
// @todo: default to 'latest' and resolve dynamically.
function configure(opts, fn){
  var valid = Object.keys(options({}));

  Object.keys(opts).map(function(k){
    if(valid.indexOf(k) === -1){
      delete opts[k];
    }
  });
  config = options(opts);

  var pkg;
  try{
    config.pkg = require(path.resolve(config.cwd + '/package.json'));
  }
  catch(err){
    return fn(new Error('Missing package.json file.  Expected to to parse\n ' +
      path.resolve(config.cwd + '/package.json')));
  }

  debug('configured: \n' + Object.keys(config).map(function(k){
    return '- '+k+': '+config[k];
  }).join('\n'));
  fs.mkdirs(config.cache, function(err){
    if(err) return fn(err);
    fn();
  });
}
Example #9
0
			dispatcher('file-rendered', config, entry.path, renderTo, rendered, function(err) {
				// TBD - the callback needs to send a new rendering
				if (err) done('Rendering file-rendered '+ entry.path +' failed with '+ err);
				else {
					logger.info('rendered '+ entry.path +' as '+ renderTo);
					if (!rendered.content) logger.error("Somethings wrong - no rendered.content");
					fs.mkdirs(path.dirname(renderTo), function(err) {
						if (err) done('FAILED to make directory '+ path.dirname(renderTo) +' failed with '+ err);
						else fs.writeFile(renderTo, rendered.content, 'utf8', function (err) {
							if (err) done(err);
							else {
								var atime = entry.stat ? entry.stat.atime : new Date();
								var mtime = entry.stat ? entry.stat.mtime : new Date();
								if (entry.frontmatter.yaml && entry.frontmatter.yaml.publDate) {
									var parsed = Date.parse(entry.frontmatter.yaml.publDate);
									if (isNaN(parsed)) {
										logger.warn("WARNING WARNING Bad date provided "+ entry.frontmatter.yaml.publDate);
										atime = mtime = new Date();
									} else {
										atime = mtime = new Date(parsed);
									}
								}
								fs.utimes(renderTo, atime, mtime, function(err) {
									sitemaps.add_sitemap_entry(config.root_url +'/'+ rendered.fname, 0.5, mtime);
									done();
								});
							}
						});
					});
				}
			});
Example #10
0
					npm.commands.install(tmpDir, [dep.name + '@' + ver], function (err) {
						if (err) { return cb(err); }

						// JIC it shows up here some how with async
						if (fs.existsSync(cacheModuleDir)) {
							// sourceModules.push(cacheModuleDir); ?? Check in sourceModules
							return cb__(null, 'cacheModuleDir already there (3) ?? -> ' + cacheModuleDir);
						}

						logger.info('Installing %s@%s %s -> %s', dep.name, ver, tmpDir, cacheModuleDir);

						fs.mkdirs(cacheModuleDir, function(err) {
							if (err) { return cb__(err); }

							var src = path.join(tmpDir, 'node_modules');

							// try to rename first - fast
							fs.rename(src, cacheModuleDir, function(err) {
								if (err) {
									// try to copy - different partitions
									copyDir(src, cacheModuleDir, function(err, cmd) {
										if (!err) {
											sourceModules.push(cacheModuleDir);
										}
										return cb__(err, err ? '' : cmd);
									});
								}
								else {
									sourceModules.push(cacheModuleDir);
									return cb__(null, 'moved node_modules to -> ' + cacheModuleDir);
								}
							});
						});
					})
Example #11
0
 return function(callback){
     var dest = ctx.path(ctx['native path'] + '/www' + ctx.toKey(file));
     ignores.push('www' + ctx.toKey(file));
     fs.mkdirs(path.dirname(dest), function(){
         ctx.copyFile(file, dest, callback);
     });
 };
Extensions.prototype.installConfigDirectory = function(options, callback) {
    var defaultconfigdir = options.configdir,
        installextconfigdir = options.extconfigdir;

    if (defaultconfigdir && installextconfigdir) {

        fs.mkdirs(installextconfigdir, function(err) {
            if (err) {
                callback(err, null);
            } else {
                async.waterfall([
                        function(cb) {
                            cb(null, {
                                ext_default_config_file_path: defaultconfigdir,
                                ext_installed_config_file_path: installextconfigdir
                            });
                        },
                        this.getExtensionConfigFiles,
                        this.copyMissingConfigFiles
                    ],
                    function(err) {
                        if (err) {
                            callback(err, null);
                        } else {
                            callback(null, 'Copied config files');
                        }
                    }.bind(this));
            }
        }.bind(this));
    } else {
        callback(null, 'No config files to copy');
    }
};
 function handleItem (item) {
   if (item.type === 'dir') {
     var dir = path.join(_this.dir, item.path)
     fs.mkdirs(dir, function (err) {
       if (err) _this.emit('error', err)
       _this._log.push(dir)
       gonnaProcess += 1
       requestJSON.call(_this, initialUrl + item.path + initialUrlRef, processItems)
       _this.emit('dir', item.path)
       pending -= 1
       checkDone()
     })
   } else if (item.type === 'file') {
     var file = path.join(_this.dir, item.path)
     fs.createFile(file, function(err) {
       if (err) _this.emit('error', err)
       request.get(rawUrl + item.path).pipe(fs.createWriteStream(file)).on('close', function() {
         _this._log.push(file)
         _this.emit('file', item.path)
         pending -= 1
         checkDone()
       })
     })
   }
   else
     _this.emit('Error', new Error(JSON.stringify(item, null, 2) + '\n does not have type.'))
 }
Example #14
0
 execNpmInstall(name + '@' + version, appDir, function(err) {
   if (err) return cb(err);
   fs.mkdirs(cachePath, function(err) {
     if (err) return cb(err);
     ncp(dest, cachePath, cb);
   });
 });
function copyOver(source, folder, filename, index, done){
    var indexed, ext, target;

    if (index === 1){
        indexed = filename;
    }else{
        ext = path.extname(filename);
        indexed = path.basename(filename, ext) + '_' + index + ext;
    }

    target = path.join(folder, indexed);

    fse.mkdirs(folder, function(err){
        if(err){
            throw err;
        }

        fs.exists(target, function(exists){
            if(exists){
                copyOver(source, folder, filename, ++index, done);
            }else{
                fse.copy(source,target, function(){
                    done(null, indexed);
                });
            }
        });
    });
}
Example #16
0
 value: function createTempDir(cb, onSuccess) {
   this.tmpdir = path.join(os.tmpdir(), 'electron-tmp-download-' + process.pid + '-' + Date.now());
   fs.mkdirs(this.tmpdir, function (err) {
     if (err) return cb(err);
     onSuccess(cb);
   });
 }
Example #17
0
  return function(fn){
    var debug = require('debug')('mongoscope-ci:' + pkg.name +':download'),
      artifacts = path.resolve(config.cache + '/.artifacts'),
      dest = path.resolve(artifacts + '/' + pkg.artifact),
      url = pkg.url,
      cleanup = createCleanupCrew('remove incomplete artifact', fs.unlinkSync.bind(null, dest)),
      start = Date.now();

    fs.mkdirs(artifacts, function(err){
      if(err) return fn(err);

        fs.exists(dest, function(exists){
          if(exists){
            debug('already have artifact ' + dest);
            cleanup.clear();
            return fn();
          }

          debug('downloading ' + url);
          var out = fs.createWriteStream(dest).on('error', fn)
            .on('finish', function(){
              debug('downloaded ' + dest + ' in ' + Math.round((Date.now() - start)/1000, 2)   + ' seconds');
              cleanup.clear();
              fn(null, dest);
            }),
            req = request(url);

          req.pipe(out);
          req.on('error', fn);
        });
    });
  };
Example #18
0
/**
 * Renders an asciidoc file into a HTML file.
 *
 * @param {string} adocFilename - The asciidoc file to render.
 */
async function asciidocToHtml(adocFilename) {
    console.log('asciidocToHtml', adocFilename);
    const relativeStylesDir = path.relative(path.dirname(adocFilename), stylesDir);
    const asocInput = await fs.readFile(adocFilename, 'utf8');
    const htmlOutput = asciidoctor.convert(asocInput, {
        safe: 'safe',
        doctype: 'article',
        header_footer: true,
        attributes: [
            'linkcss',
            `stylesdir=${relativeStylesDir}`,
            'experimental',
            'sectlinks',
            'idprefix=',
            'idseparator=-',
            'source-highlighter=highlightjs',
        ],
        base_dir: path.dirname(adocFilename),
    });
    const outputFilename = path.join(destDir, path.dirname(adocFilename), path.basename(adocFilename, '.adoc')) + '.html';
    await fs.mkdirs(path.dirname(outputFilename));

    if (path.basename(adocFilename) === 'README.adoc') {
        const indexOutputFilename = path.join(destDir, path.dirname(adocFilename), 'index.html');
        await fs.writeFile(indexOutputFilename, htmlOutput);
        await writeRedirectPage(outputFilename);
    } else {
        await fs.writeFile(outputFilename, htmlOutput);
    }
}
Example #19
0
Screenstory.prototype.save = function save(image, options, cb) {
    var self = this;

    // extract browser id from capabilities
    if (!options.capabilities) {
        return cb(new VError('Option "capabilities" is required.\nHINT: You can provide "client.desiredCapabilities".'));
    }
    var id = dasherize(options.id || options.title || this.data.length);

    options.browserId = this.browserId(options.capabilities);
    options.storyId = options.storyId || dasherize(options.story);
    options.title = options.title || id;
    options.imageUrl = 'data:image/png;base64,' + image.toString('base64');

    var dest = this.generatePath(options.capabilities, options.storyId, id + '.png');
    // we are about to create parent directory
    var screenshotsDir = path.dirname(dest);

    fse.mkdirs(screenshotsDir, function writeScreenshotFile(err) {
        if (err) { return cb(err); }

        fs.writeFile(dest, image.value, 'base64', function pushDataToScreenstory(err) {
            if (err) { return cb(err); }

            options.fullpath = dest;
            self.data.push(options);

            cb();
        });
    });

    return dest;
};
Example #20
0
fs.remove(tempdir, function(err) {
	if (err) return error(err);
	fs.mkdirs(tempdir, function(err) {
		if (err) return error(err);
		process.exit(0);
	});
});
        async.eachSeries(files, function(item, callback) {
            var source = item.src.toString(), // Why is this an OBJECT?
                destination = item.dest;

            if (source === undefined) {
                callback('source not defined');
            }
            if (destination === undefined) {
                callback('destination not defined');
            }

            grunt.log.writeln('Copying directory "' + source + '" to "' + destination + '"');
            fs.mkdirs(destination, function (err) {
                if (err) {
                    callback (err);
                }

                fs.copy(source, destination, function (err) {
                    if (err) {
                        callback (err);
                    }

                    callback(null);
                });
            });
        }, function (err) {
/**
 * Private function to unzip to the correct directory.
 *
 * @param {string} Absolute path to the package zip file
 * @param {string} Absolute path to the destination directory for unzipping
 * @param {Object} the return value with the useful information for the client
 * @param {Function} callback function that is called at the end of the unzipping
 */
function _performInstall(packagePath, installDirectory, validationResult, callback) {
    validationResult.installedTo = installDirectory;
    
    var callbackCalled = false;
    
    fs.mkdirs(installDirectory, function (err) {
        if (err) {
            callback(err);
            return;
        }
        var readStream = fs.createReadStream(packagePath);
        var extractStream = unzip.Parse();
        var prefixlength = validationResult.commonPrefix ? validationResult.commonPrefix.length : 0;
        
        readStream.pipe(extractStream)
            .on("error", function (exc) {
                if (!callbackCalled) {
                    callback(exc);
                    callbackCalled = true;
                    readStream.destroy();
                    _removeFailedInstallation(installDirectory);
                }
            })
            .on("entry", function (entry) {
                var installpath = entry.path;
                if (prefixlength) {
                    installpath = installpath.substring(prefixlength + 1);
                }
                if (entry.type === "Directory") {
                    if (installpath === "") {
                        return;
                    }
                    try {
                        fs.mkdirsSync(installDirectory + "/" + installpath);
                    } catch (e) {
                        callback(e);
                        callbackCalled = true;
                        _removeFailedInstallation(installDirectory);
                    }
                } else {
                    entry.pipe(fs.createWriteStream(installDirectory + "/" + installpath))
                        .on("error", function (err) {
                            if (!callbackCalled) {
                                callback(err);
                                callbackCalled = true;
                                readStream.destroy();
                                _removeFailedInstallation(installDirectory);
                            }
                        });
                }
                
            })
            .on("end", function () {
                if (!callbackCalled) {
                    callback(null, validationResult);
                    callbackCalled = true;
                }
            });
    });
}
/**
 * Private function to unzip to the correct directory.
 *
 * @param {string} Absolute path to the package zip file
 * @param {string} Absolute path to the destination directory for unzipping
 * @param {Object} the return value with the useful information for the client
 * @param {Function} callback function that is called at the end of the unzipping
 */
function _performInstall(packagePath, installDirectory, validationResult, callback) {
    validationResult.installedTo = installDirectory;
    
    var callbackCalled = false;
    
    fs.mkdirs(installDirectory, function (err) {
        if (err) {
            callback(err);
            return;
        }
        var sourceDir = path.join(validationResult.extractDir, validationResult.commonPrefix);
        
        fs.copy(sourceDir, installDirectory, function (err) {
            if (err) {
                _removeFailedInstallation(installDirectory);
                callback(err, null);
            } else {
                // The status may have already been set previously (as in the
                // DISABLED case.
                if (!validationResult.installationStatus) {
                    validationResult.installationStatus = Statuses.INSTALLED;
                }
                callback(null, validationResult);
            }
        });
    });
}
Example #24
0
		return FS.exists(PATH.dirname(path), function (exists) {
			if (exists) return callback(null, path);
			return FS.mkdirs(PATH.dirname(path), function(err) {
				if (err) return callback(err);
				return callback(null, path);
			});
		});
Example #25
0
exports.getQueue = async.queue(function (file, callback) {
  if (!file || _.isEmpty(file)) callback(new Error("File doesn't exist"))
  let parentPath = global.state.rfs[file.parents[0]].path
  const dir = `${global.paths.home}${parentPath}`
  const path = (parentPath === '/') ? `${dir}${file.name}` : `${dir}/${file.name}`
  file.path = path

  fs.mkdirs(dir, function (err) {
    if (err) callback(err)
    // logger.verbose(`GETing ${file.name} at dest ${path}`)
    let dest = fs.createWriteStream(path)

    global.drive.files.get({
      fileId: file.id,
      alt: 'media'
    })
      .on('error', function (err) {
        logger.error('Error during download', err)
        callback(err)
      })
      .pipe(dest)
      .on('error', function (err) {
        logger.error('Error during writting to fs', err)
        callback(err)
      })
      .on('finish', function () {
        // logger.verbose(`Written ${file.name} to ${path}`)
        // exports.event.emit('got', file)
        callback(null, file)
      })
  })
}, CONCURRENCY)
Example #26
0
      writejqversion(dddpkgpath, jqpkg.version, pkgVersionInc, function(err, dddversion) {
        if (err) throw err;
        console.log('[prepublish]', 'ddd-jquery', dddversion);

        // browserify ../jquery > ../dist/jquery.{min.,}js to be able to
        // run the tests.
        // NOTE: not important whatsoever to the actual package, just for
        // trying to run the jQuery tests with the transformed files.
        var dist = path.join(destpath, 'dist');
        fs.mkdirs(dist, function(err) {
          if (err) {
            console.log('[prepublish]', err);
            return;
          }
          var b = browserify();
          b.add(path.join(destpath, 'jquery.js'));
          var bundle = b.bundle();
          bundle.pipe(fs.createWriteStream(path.join(dist, 'jquery.min.js')))
          bundle.pipe(fs.createWriteStream(path.join(dist, 'jquery.js')))
        });

        // Lastly, perform the santity check that we are ready to publish.
        sanitycheck(destpath, function(err) {
          if (err) throw err;
          console.log('[sanitycheck]', 'CAST IN THE NAME OF SCIENCE, YE ARE SANE.')
          process.exit(0);
        })
      })
Example #27
0
 beforeEach(function (done) {
     fs.mkdirs(installDirectory, function (err) {
         fs.mkdirs(disabledDirectory, function (err) {
             done();
         });
     });
 });
Example #28
0
  /**
   * get uploaded image filename
   */
  getFilename (image) {
    const date = new Date()
    const timestamp = date.getTime()
    const year = this.padLeft(date.getYear() + 1900, 4)
    const month = this.padLeft(date.getMonth() + 1, 2)
    const day = this.padLeft(date.getDate(), 2)

    const random = Math.random().toString().substr(-8)

    const ext = path.extname(image.name)
    const name = path.basename(image.name, ext)

    const pathname = this.format.toLowerCase()
      .replace(/{timestamp}/g, timestamp)
      .replace(/{yyyy}/g, year)
      .replace(/{mm}/g, month)
      .replace(/{dd}/g, day)
      .replace(/{name}/g, name)
      .replace(/{ext}/g, ext)
      .replace(/{random}/g, random)
      .replace(/{uuid}/g, uuid())

    const filename = path.join(this.localPath, pathname)
    const pathObj = path.parse(filename)

    return fs.mkdirs(pathObj.dir).then(() => this.unique(pathObj))
  }
Example #29
0
	fs.readdir(themedir, function (err
		//, files
	) {
		// console.log('files',files);
		if (err) {
			asynccallback(null,'No Public Directory to Copy');
		}
		else {
			//make destination dir
			fs.mkdirs(themepublicdir, function (err) {
				if (err) {
					asynccallback(err,null);
				}
				else {
					fs.copy(themedir, themepublicdir, function (err) {
						if (err) {
							asynccallback(err,null);
						}
						else {
							asynccallback(null,'Copied public files');
						}
					});
				}
			});
		}
	});
Example #30
0
    return new Promise((resolve, reject) => {
      fs.mkdirs(dest, (err) => {
        if (err) return reject(err)
        const options = {
          dereference: true, // same meaning as `-L` of `rsync` command
          filter: (src, dest) => {
            if (!program.prebuiltDirectory && src === 'package.json') {
              // include package.json unless prebuiltDirectory is set
              return true
            }

            if (!minimatch(src, pattern, { matchBase: true })) {
              return true
            }
            // Directory check. Even if `src` is a directory it will not end with '/'.
            if (!dirPatternRegExp.test(src)) {
              return false
            }
            return !fs.statSync(src).isDirectory()
          }
        }
        fs.copy(src, dest, options, (err) => {
          if (err) return reject(err)
          resolve()
        })
      })
    })