How to use the fs.writeFile function in fs

To help you get started, we’ve selected a few 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 jupyter-widgets / ipywidgets / ipywidgets / copy_version.js View on Github external
if (dev) {
    minor = String(parseInt(minor) + 1);
}

// Generate the version file contents.
var contents =
    "# DO NOT EDIT!  NPM AUTOMATICALLY WRITES THIS FILE!\nversion_info = (" +
    major + ", " +
    minor + ", " +
    patch +
    (dev ? ", 'dev'" : "") +
    ")\n__version__ = '.'.join(map(str, version_info))\n";

// Write the contents to the file.
var fs = require("fs");
fs.writeFile("_version.py", contents, function(err) {
    if(err) {
        console.error("Could not write the Python version file", err);
        process.exit(1);
    } else {
        console.log("Python version " + major + "." + minor + "." + patch + (dev ? "dev" : "") + " written");
    }
});
github Mermade / shins / buildstyle.js View on Github external
}, function(err, result) {
		if (err) console.error(err)
		else {
			fs.writeFile(outfile,result.css.toString(),'utf8',function(err){
                if (err) console.warn(err.message);
            });
        }
	});
}
github essepuntato / rash / sources / raje / app / old / main / fs_utils.js View on Github external
.end((err, res) => {
        if (err) callback(err)

        let filepath = url.split('/')[url.split('/').length - 1]

        if (!fs.existsSync(filepath) || (fs.existsSync(filepath) && fs.writeFileSync(filepath) != res.body)) {
          fs.writeFile(filepath, res.body, (err) => {
            callback(null, filepath)
          })
        }
      })
  }
github Acheron-VAF / Acheron / UI / app / renderers / settings-control.js View on Github external
export default function updateSettings(newsettings) {

  //console.log(settingsconf)
  //console.log(newsettings)

  if (!fs.existsSync(prismdir)) {
      fs.mkdirSync(prismdir);
      fs.writeFile(settingsconf, '{"test":"tmp"}');
  }

  //Get current configuration
  //let curconf = JSON.parse(fs.readFileSync(settingsconf));
  //console.log(curconf)


  fs.writeFile(settingsconf, JSON.stringify(newsettings), function(err) {
    if(err) {
        return console.log(err);
    }

    console.log("Prismatica configuration updated!");
  });
}
github bbc / ShouldIT / index.js View on Github external
specCollector(config.glob, function(specs) {
    fs.writeFile(config.specFile, JSON.stringify(specs, null, 4), function (err) {
        if (err) throw err;
        fileCollector(config.specFile, config.comparisonFile, function(files){
            var results = inspector(files);
            var output = spitterOuter(results);
            for (var i = 0; i < output.length; i++) {
                console.log(output[i]);
            }
        });
    });
});
github kura52 / sushi-browser / electron-patch-resources / browser / extensions / tabs-main.js View on Github external
contents.printToPDF({landscape: pageSettings.orientation === 1}, (error, data) => {
          if (error) {
            cb('not_saved')
            return
          }
          fs.writeFile(filepaths[0], data, (error) => {
            if (error) {
              cb('not_saved')
              return
            }
            cb('saved')
          })
        })
      })
github jakubpawlowicz / assets-packager / lib / packager.js View on Github external
return function(callback) {
      fs.writeFile(groupPath, data.embedded.plain, 'utf-8', callback);
    };
  };
github mozilla / napkin / export / index.js View on Github external
templateContextMap[templatePath](project, req, db, function(data) {
            var template = handlebars.compile(contents);
            var newContents = template(data);

            fs.writeFile(filePath, newContents, function(err) {
              if (err) {
                throw err;
              }
            });
          });
        });
github Jiiks / BetterDiscordApp / src / core / modules / csseditor.js View on Github external
saveCss(event, css) {
        _bd_fs.writeFile(`${_bd_config.dataPath}/custom.css`, css, 'utf-8', err => {
            if (err) {
                event.sender.send('save-error', err);
                return;
            }
            event.sender.send('save-ok');
        });
    }
}

fs

This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.

ISC
Latest version published 8 years ago

Package Health Score

70 / 100
Full package analysis