How to use the fs.readFileSync 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 uupaa / WebModule / run / minify.js View on Github external
function _parseCommandLineOptions(options) {
    for (var i = 0, iz = argv.length; i < iz; ++i) {
        switch (argv[i]) {
        case "-h":
        case "--help":      options.help = true; break;
        case "-v":
        case "--verbose":   options.verbose = true; break;
        case "--nowrap":    options.nowrap = true; break;
        case "--header":    options.header = fs.readFileSync(argv[++i], "utf8"); break;
        case "--footer":    options.footer = fs.readFileSync(argv[++i], "utf8"); break;
        case "--es5in":     options.es5in = true; break;
        case "--es6in":     options.es6in = true; break;
        case "--es5out":    options.es5out = true; break;
        case "--es6out":    options.es6out = true; break;
        case "--strict":    break; // [DEPRECATED]
        case "--keep":      options.keep = true; break;
        case "--simple":    break; // [DEPRECATED]
        case "--extern":
        case "--externs":   _pushif(options.externs, argv[++i]); break;
        case "--option":    _pushif(options.option, argv[++i]); break;
        case "--pretty":    options.pretty = true; break;
        case "--optimize":  _pushif(options.externs, argv[++i]); break;
        case "--concat":    options.optimize = 0;
                            options.include_modules = true; break;
        case "--debug":     options.optimize = 1;
github jellyfin / jellyfin-react-client / scripts / install.js View on Github external
const path = `node_modules/${packageName}/${name}.js`
  const data = readFileSync(path, 'utf8')

  writeFileSync(path, data.replace(src, dest))
}

// Fix versions in `react-native-sensitive-info` directly

const path_csproj = `node_modules/react-native-sensitive-info/windows/RNSensitiveInfo/RNSensitiveInfo/RNSensitiveInfo.csproj`
const data_csproj = readFileSync(path_csproj, 'utf8')

writeFileSync(path_csproj, data_csproj.replace('10.0.10586.0', '10.0.14393.0'))

const path_project = `node_modules/react-native-sensitive-info/windows/RNSensitiveInfo/RNSensitiveInfo/project.json`
const path_projectlock = `node_modules/react-native-sensitive-info/windows/RNSensitiveInfo/RNSensitiveInfo/project.lock.json`
const data_project = readFileSync(path_project, 'utf8')

writeFileSync(path_project, data_project.replace('"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",', '"Microsoft.NETCore.UniversalWindowsPlatform": "6.0.6",').replace("uap10.0","uap10.0.14393"))
unlinkSync(path_projectlock)

// Replace usage of `react-native-web` for `react-native-web_improved`
replace.call({
  dest: 'react-native-web_improved',
  packageName: 'babel-plugin-react-native-web',
  src: 'react-native-web'
}, 'index')
github saltyshiomix / react-ssr / packages / express / lib / core / utils.ts View on Github external
const performBabelRequire = (filename: string) => {
  workingParentFile = filename;
  const { code } = require('@babel/core').transform(readFileSync(filename).toString(), {
    filename,
    ...(getBabelPresetsAndPlugins()),
  });
  return requireFromString(code, filename);
  // return requireFromString(code);
};
github lantanagroup / FHIR.js / test / fhirPath.js View on Github external
var Fhir = require('../fhir').Fhir;
var FhirPath = require('../fhirPath').FhirPath;
var fs = require('fs');
var assert = require('assert');
var _ = require('underscore');

var documentBundleJson = fs.readFileSync('./test/data/stu3/document-example-dischargesummary.json').toString();
var questionnaireResponseJson = fs.readFileSync('./test/data/r4/QuestionnaireResponse_01.json').toString();

describe('FhirPath', function() {
    var resource = JSON.parse(documentBundleJson);

    describe('parse', function() {
        var fhirPath = new FhirPath(resource);

        it('should parse a simple path', function() {
            var parsed = fhirPath.parse('Bundle.entry.fullUrl');
            assert(parsed);
            assert(parsed.length === 1);
            assert(parsed[0].path);
            assert(parsed[0].path.length === 2);
            assert(parsed[0].path[0] === 'entry');
            assert(parsed[0].path[1] === 'fullUrl');
        });
github maxogden / data-plumber / problems / gasket / index.js View on Github external
var fs = require('fs')
var os = require('os')
var path = require('path')
var child = require('child_process')
var ansimd = require('ansimd')
var compare = require('../../compare.js')

var spawn = child.spawn
if (os.type() === 'Windows_NT') spawn = require('win-spawn')

var gasketCmd = path.resolve(__dirname, '..', '..', 'node_modules', 'gasket', 'bin.js')

exports.problem = ansimd(fs.readFileSync(path.join(__dirname, 'problem.md')).toString())
exports.solution = "Reference solution:\n\n" + fs.readFileSync(path.join(__dirname, 'package.json')).toString() + '\n'

exports.verify = function(args, cb) {
  var entry = spawnEntry(args)
  var solution = spawnSolution()
  compare(entry, solution, cb)
}

exports.run = function(args) {
  var entry = spawnEntry(args)
  console.error('gasket', 'run', '--config', path.resolve(args[0]))
  entry.stdout.pipe(process.stdout)
  entry.stderr.pipe(process.stderr)
}

function spawnEntry(args) {
  var entryCmd = gasketCmd
github Ked57 / NIOD / src / utils / config.js View on Github external
exports.loadConfig = () => {
  let configData = {};
  try {
    const configJSON = fs.readFileSync("config.json");
    configData = JSON.parse(configJSON);
  } catch (e) {
    niod_console.error(e);
    return;
  }
  for (const property of Object.keys(this.config)) {
    if (configData.property) {
      this.config[property] = configData[property];
    }
  }
  niod_console.log("Config file loaded");
};
github pankod / next-boilerplate / project-cli / dist / helper_scripts / definations / helper.js View on Github external
const templatePath = './helper_scripts/templates/interfaces/component.d.mustache';
        const templateProps = { fileName, isClass, lowerFileName, isConnectStore };
        const pageDirPath = `${exports.Config.pageInterfaceDir}/${fileName}.d.ts`;
        const compDirPath = `${exports.Config.compInterfaceDir}/${fileName}.d.ts`;
        const pageInterfaceIndex = './helper_scripts/templates/interfaces/page-index.d.mustache';
        const compIntefaceIndex = './helper_scripts/templates/interfaces/component-index.d.mustache';
        const storeInterface = './helper_scripts/templates/interfaces/redux-store.d.mustache';
        const storeImportInterface = './helper_scripts/templates/interfaces/redux-import.d.mustache';
        const writeFileProps = {
            dirPath: isPage ? pageDirPath : compDirPath,
            getFileContent: () => exports.Helper.getTemplate(templatePath, templateProps),
            message: 'Added new interface file'
        };
        const replaceContentParams = {
            fileDir: `${exports.Config.interfaceDir}/index.ts`,
            filetoUpdate: fs.readFileSync(path.resolve('', `${exports.Config.interfaceDir}/index.ts`), 'utf8'),
            getFileContent: () => exports.Helper.getTemplate(isPage ? pageInterfaceIndex : compIntefaceIndex, templateProps),
            message: 'Interface file added to Interfaces/index.ts',
            regexKey: isPage ? /...PAGE INTERFACES/g : /...COMPONENT INTERFACES/g
        };
        const replaceStoreParams = {
            fileDir: `${exports.Config.reduxInterfaceDir}/Store.d.ts`,
            filetoUpdate: fs.readFileSync(path.resolve('', `${exports.Config.reduxInterfaceDir}/Store.d.ts`), 'utf8'),
            getFileContent: () => exports.Helper.getTemplate(storeInterface, templateProps),
            message: 'Interface file added to Interfaces/Redux/Store.d.ts',
            regexKey: /export type IStore\s[=]\s[{]/g
        };
        exports.Helper.writeFile(writeFileProps);
        exports.Helper.replaceContent(replaceContentParams);
        if (isConnectStore) {
            exports.Helper.replaceContent(replaceStoreParams);
            setTimeout(() => {
github h2non / youtube-video-api / index.js View on Github external
function oauthLazyHandshake (tokens, cb) {
  const file = this.opts.file || CREDENTIALS_FILENAME
  const fetchCredentials = setCredentials.call(this, cb)

  if (!tokens && fs.existsSync(file)) {
    tokens = JSON.parse(fs.readFileSync(file))
  }

  if (tokens && tokens.access_token) {
    return fetchCredentials(null, tokens)
  }

  getAccessToken.call(this, fetchCredentials)
}
github pmsaue0 / play / app / main.js View on Github external
function stylePlayer() {
  var theme = fs.readFileSync(path.join(__dirname, 'themes', 'theme.css'), "utf8");

  mainWindow.webContents.insertCSS('#player paper-icon-button[data-id="show-miniplayer"] { display: none; }');
  mainWindow.webContents.insertCSS(theme);
}
github endel / js-inheritance-benchmark / index.js View on Github external
const fs = require('fs');
const present = require('present');

const targets = {
  vanilla: { module: require('./vanilla'), source: fs.readFileSync('./vanilla/index.js').toString() },
  vanillaPromote: { module: require('./vanilla-promote'), source: fs.readFileSync('./vanilla-promote/index.js').toString() },
  ts: { module: require('./ts'), source: fs.readFileSync('./ts/index.js').toString() },
  babel: { module: require('./es6/index-babel.js'), source: fs.readFileSync('./es6/index-babel.js').toString() },
  buble: { module: require('./es6/index-buble.js'), source: fs.readFileSync('./es6/index-buble.js').toString() },
  es6: { module: require('./es6/index.js'), source: fs.readFileSync('./es6/index.js').toString() },
};

const numLoops = 10;

let suites = [];
let executionTable = [];
let executionRow = [];

let memoryTable = [];
let memoryRow = [];
let previousMemory = null;
function addExecutionRow(elapsedTime) {
  executionRow.push(elapsedTime.toFixed(2) + "ms");

  let currentMemory = process.memoryUsage();

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

67 / 100
Full package analysis