How to use the fs-extra.readJsonSync function in fs-extra

To help you get started, we’ve selected a few fs-extra 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 unfoldingWord / translationCore / src / js / helpers / ToolsMetadataHelpers.js View on Github external
moduleFolderPathList.forEach((fullPathName) => {
    const moduleFolderName = fullPathName.split('package.json')[0];
    const modulePath = path.join(moduleFolderName, 'package.json');
    const dataObject = fs.readJsonSync(modulePath);
    const checkArray = LoadHelpers.createCheckArray(dataObject, moduleFolderName);

    for (let module of checkArray) {
      try {
        let tool = require(path.join(module.location, dataObject.main)).default;

        // TRICKY: compatibility for older tools
        if ('container' in tool.container && 'name' in tool.container) {
          tool = tool.container;
        }
        // end compatibility fix
        currentToolViews[module.name] = tool.container;

        if (tool.api) {
          apis[module.name] = tool.api;
        }
github pterodactyl / daemon / scripts / diagnostics.js View on Github external
Fs.access('./config/core.json', (Fs.constants || Fs).R_OK | (Fs.constants || Fs).W_OK, err => { // eslint-disable-line
                if (err) return callback(null, { error: true });
                return callback(null, Fs.readJsonSync('./config/core.json'));
            });
        },
github jasperapp / jasper / src / index.ts View on Github external
{
    const configs = fs.readJsonSync(configPath);
    if (!('https' in configs[0].github)) {
      configs[0].github.https = true;
      fs.writeJsonSync(configPath, configs);
    }

    if (!('badge' in configs[0].general)) {
      configs[0].general.badge = false;
      fs.writeJsonSync(configPath, configs);
    }
  }

  // migration: to v0.2.1 from v0.2.0
  {
    const configs = fs.readJsonSync(configPath);
    if (!('alwaysOpenOutdated' in configs[0].general)) {
      configs[0].general.alwaysOpenOutdated = false;
      fs.writeJsonSync(configPath, configs);
    }
  }

  // migration: to v0.4.0
  {
    const configs = fs.readJsonSync(configPath);
    if (!('theme' in configs[0])) {
      for (const config of configs) config.theme = {main: null, browser: null};
      fs.writeJsonSync(configPath, configs, {spaces: 2});
    }
  }

  Config.initialize(configPath);
github philipwalton / easy-sauce / lib / cli.js View on Github external
function getPackageOpts() {
  try {
    // Getting the packpage path from process.cwd allows it to be stubbed.
    const pkgPath = path.resolve(process.cwd(), './package.json');
    return fs.readJsonSync(pkgPath).easySauce;
  } catch (err) {
    // Do nothing.
  }
}
github strongloop / loopback-workspace / test / facet.js View on Github external
it('omits `facetName` in model-config.json', function() {
      const content = fs.readJsonSync(SANDBOX + '/server/model-config.json');
      expect(content.User).to.not.have.property('facetName');
    });
github mdasberg / ng-apimock / test / protractor / step_definitions / interface.steps.js View on Github external
defineSupportCode(function({Given, When, Then, setDefaultTimeout}) {

        setDefaultTimeout(60 * 1000);

        const fs = require('fs-extra');
        const path = require('path');
        const mockingPo = new (require('./../po/mocking.po'))();
        const mocksDirectory = path.join(process.cwd(), 'test', 'mocks', 'api');
        const responses = {
            list: fs.readJsonSync(path.join(mocksDirectory, 'some-api-list.json')).responses,
            insert: fs.readJsonSync(path.join(mocksDirectory, 'some-api-insert.json')).responses,
            update: fs.readJsonSync(path.join(mocksDirectory, 'some-api-update.json')).responses,
            download: fs.readJsonSync(path.join(mocksDirectory, 'some-api-download.json')).responses
        };

        Then(/^I switch to test page$/, () => browser.getAllWindowHandles()
            .then((handles) => browser.driver.switchTo().window(handles[1])
                .then(() => browser.driver.close()
                    .then(() => browser.driver.switchTo().window(handles[0])))));

        Given(/^a mock with name (.*) has marked (.*) as its default scenario$/, (name, scenario) =>
            expect(responses[name][scenario]['default']).to.be.true);

        Given(/^a mock with name (.*) has no scenario marked as default$/, (name) =>
            expect(Object.keys(responses[name])
                .filter(function (scenario) {
                    return responses[name][scenario].default || false;
                }).length).to.equal(0));
github microsoft / Orb / dist / resources / app / resourceEditor / resourceEditor.tsx View on Github external
removeOriginalResourceIfNeeded(): Promise {
        if (this.addNewResource) {
            return Promise.resolve();
        }

        let fullPath = "";
        let newFileContent = null;

        for (let i = 0; i < this.state.filePathSrc.length; i++) {
            const filePath = path.join(this.modelDir, this.state.filePathSrc[i]);
            const fileContent = fsExtra.readJsonSync(filePath);
            let resources = fileContent.resources;
            let indexToRemove = -1;

            for (let j = 0; j < resources.length; j++) {
                if (resources[j].relativePath == this.originalRelativePath) {
                    indexToRemove = j;
                    break;
                }
            }

            if (indexToRemove > -1) {
                resources.splice(indexToRemove, 1);
                fileContent.resources = resources;
                newFileContent = fileContent;
                fullPath = filePath;
                break;
github pingyhq / pingy-cli / packages / scaffold-middleware / index.js View on Github external
function pingyApi(resolve, scaffoldPath) {
  const scaffoldJsonPath = path.join(scaffoldPath, 'pingy-scaffold.json');
  const baseScaffold = fs.readJsonSync(scaffoldJsonPath, { throws: false });
  return (req, res) => {
    const body = req.body || {};
    const { scaffold } = body;
    if (!scaffold) res.send({});
    const mergedScaffold = mergeScaffolds(baseScaffold, scaffold);
    resolve(mergedScaffold);
    res.send(mergedScaffold);
  };
}