How to use the graceful-fs.writeFile function in graceful-fs

To help you get started, we’ve selected a few graceful-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github klaemo / s3-website / index.js View on Github external
fromFile = {}
    }

    var dirty = Object.keys(fromCL).some(function (key) { // Test if anything has changed
      return fromFile[key] !== fromCL[key]
    })

    var config = Object.assign(defaultConfig, fromFile, fromCL) // Merge arguments and file parameters

    if (!config.domain) {
      console.log('No bucket was specified. Check your config file ' + path)
      return
    }

    if (dirty && !config.lockConfig) { // Something has changed rewrite file, and we are allowed to write config file
      fs.writeFile(fromCL.configFile, JSON.stringify(config, null, 3), function (err) {
        if (err) console.error(err)
        console.log('Updated config file: ' + fromCL.configFile)
        cb(err, config)
      })
    } else { // No change, we're done
      cb(err, config)
    }
  })
}
github uber / npm-shrinkwrap / set-resolved.js View on Github external
json['npm-shrinkwrap-version'] = version;

        json['node-version'] = process.version;

        json = fixResolved(json, null);

        // if top level shrinkwrap has a `from` or `resolved`
        // field then delete them
        if (json.from) {
            json.from = undefined;
        }
        if (json.resolved) {
            json.resolved = undefined;
        }

        fs.writeFile(shrinkwrapFile,
            JSON.stringify(json, null, 2) + '\n', callback);
    }
github uber-archive / idl / test / idl.js View on Github external
function onRawMetaJson(err, rawJson) {
            if (err) {
                return callback(err);
            }
            var lines = rawJson.split('\n');
            rawJson = lines.slice(0, lines.length - 2).join('\n');
            fs.writeFile(metaPath, rawJson, 'utf8', callback);
        }
    };
github onmyway133 / PushNotifications / node_modules / fs-extra / lib / ensure / file.js View on Github external
function makeFile () {
    fs.writeFile(file, '', function (err) {
      if (err) return callback(err)
      callback()
    })
  }
github mallocator / Elasticsearch-Exporter / drivers / file.driver.js View on Github external
write: (file, overwrite, index, type, name, data, callback) => {
                let directory = this.archive.path(file, index, type, name);
                if (!this.archive.files[directory]) {
                    this.archive.createParentDir(directory);
                    this.archive.files[directory] = true;
                }
                if (overwrite) {
                    fs.writeFile(directory, data, 'utf8', callback);
                } else {
                    fs.appendFile(directory, '\n' + data, 'utf8', callback);
                }
            },
            read: (file, index, type, name, callback) => {
github tidys / CocosCreatorPlugins / packages / excel-killer / node_modules / fs-extra / lib / output / index.js View on Github external
pathExists(dir, (err, itDoes) => {
    if (err) return callback(err)
    if (itDoes) return fs.writeFile(file, data, encoding, callback)

    mkdir.mkdirs(dir, err => {
      if (err) return callback(err)

      fs.writeFile(file, data, encoding, callback)
    })
  })
}
github IDEO-coLAB / smirk / src / main / index.js View on Github external
ipcMain.on('DOWNLOAD_FILE', (event, args) => {
  fs.writeFile(`${DOWNLOAD_PATH}/${args.filename}`, args.filedata, (error) => {
    if (error) {
      event.sender.send('FILE_DOWNLOAD_ERROR')
      return
    }
    event.sender.send('FILE_DOWNLOAD_SUCCESS')
  })
})
github jspm / jspm-cli / lib / config / config-file.js View on Github external
    await new Promise((resolve, reject) => fs.writeFile(filePath, serializeJson(json, style), err => err ? reject(err) : resolve()));
}
github graalvm / graaljs / deps / npm / node_modules / cmd-shim / index.js View on Github external
+ "if [ -x "+shLongProg+" ]; then\n"
       + "  " + shLongProg + " " + args + " " + shTarget + " \"$@\"\n"
       + "  ret=$?\n"
       + "else \n"
       + "  " + shProg + " " + args + " " + shTarget + " \"$@\"\n"
       + "  ret=$?\n"
       + "fi\n"
       + "exit $ret\n"
  } else {
    sh = shProg + " " + args + " " + shTarget + " \"$@\"\n"
       + "exit $?\n"
  }

  var then = times(2, next, cb)
  fs.writeFile(to + ".cmd", cmd, "utf8", then)
  fs.writeFile(to, sh, "utf8", then)
  function next () {
    chmodShim(to, cb)
  }
}
github gameclosure / devkit / src / PackageManager.js View on Github external
this.saveManifest = function (data, cb) {
		this.manifest = data;
		return fs.writeFile(path.join(this.paths.root, 'manifest.json'), serializeConfig(data), cb);
	};