How to use the load-json-file.sync function in load-json-file

To help you get started, we’ve selected a few load-json-file 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 Turfjs / turf / scripts / update-export-default-typescript.js View on Github external
glob.sync(path.join(__dirname, '..', 'packages', 'turf-*', 'index.js')).forEach(filepath => {
    let index = fs.readFileSync(filepath, 'utf8');
    const dir = path.parse(filepath).dir;
    const pckg = load.sync(path.join(dir, 'package.json'));
    const name = camelcase(pckg.name).replace('@turf/', '');

    // Modules without named export function
    if (index.includes('export default function (')) {
        // duplicate function names
        if (index.includes('function ' + name)) {
            throw new Error('duplicate function name', name);
        }
        index = index.replace('export default function (', `function ${name}(`);
        index += `\nexport default ${name};`;
        index += `\nmodule.exports.default = ${name};\n`;
        fs.writeFileSync(filepath, index);
    }
    // Modules with named export function
    if (index.includes(`export default function ${name}(`)) {
        index = index.replace(`export default function ${name}(`, `function ${name}(`);
github apifytech / apify-cli / test / commands / push.js View on Github external
it('should work without actorId', async () => {
        const apifyJson = loadJson.sync('apify.json');
        apifyJson.env = {
            MY_ENV_VAR: 'envVarValue',
        };
        writeJson.sync('apify.json', apifyJson);

        await command.run(['push']);

        const userInfo = await getLocalUserInfo();
        const { name } = apifyJson;
        const actorId = `${userInfo.username}/${name}`;
        const createdActor = await testUserClient.acts.getAct({ actId: actorId });
        const createdActorVersion = await testUserClient.acts.getActVersion({
            actId: actorId,
            versionNumber: apifyJson.version,
        });
        const store = await testUserClient.keyValueStores.getOrCreateStore({ storeName: UPLOADS_STORE_NAME });
github webiny / webiny-js / packages / webiny-cli / src / apps / build.js View on Github external
module.exports = async ({ name }) => {
    const { env, ssr } = await getAppConfig(name);

    const cwd = path.resolve(`packages/${name}`);
    await execa("yarn", ["build"], {
        cwd,
        env: { ...env, REACT_APP_ENV: "browser" },
        stdio: "inherit"
    });

    if (ssr) {
        const pkg = loadJson.sync(path.join(cwd, "package.json"));
        if (!get(pkg, "scripts.build:ssr")) {
            logger.error(
                `%s doesn't have a script "build:ssr"! This script is mandatory for SSR enabled apps.`,
                name
            );
            process.exit(1);
        }

        await execa("yarn", ["build:ssr"], {
            cwd,
            env: { ...env, REACT_APP_ENV: "ssr" },
            stdio: "inherit"
        });
    }
};
github Turfjs / turf / src / boolean-equal / bench.js View on Github external
glob.sync(path.join(__dirname, 'test', '**', '*.geojson')).forEach(filepath => {
    const {name} = path.parse(filepath);
    const geojson = load.sync(filepath);
    const [feature1, feature2] = geojson.features;
    console.time(name);
    equal(feature1, feature2);
    console.timeEnd(name);
    suite.add(name, () => equal(feature1, feature2));
});
github Turfjs / turf / src / directional-mean / bench.js View on Github external
glob.sync(path.join(__dirname, 'test', 'in', '*.json')).forEach(filepath => {
    const { name } = path.parse(filepath);
    const geojson = load.sync(filepath);
    if (name === 'bus_route_gps.json') {
        console.time(name);
        directionalMean(geojson, {
            planar: false
        })
        console.timeEnd(name);
        console.time(name + ' segment');
        directionalMean(geojson, {
            planar: false,
            segment: true
        })
        console.timeEnd(name + ' segment');
        suite.add(name, () => directionalMean(geojson, {
            planar: false,
        }));
        suite.add(name + ' segment', () => directionalMean(geojson, {
github Turfjs / turf / packages / turf-centroid / bench.js View on Github external
const fixtures = glob.sync(path.join(__dirname, 'test', 'in', '*.geojson')).map(input => {
    return {
        name: path.parse(input).name,
        geojson: load.sync(input)
    }
});
github egoist / use-config / src / index.js View on Github external
fallbackLoader(filepath) {
          return this.sync
            ? loadJsonFile.sync(filepath)
            : loadJsonFile(filepath)
        }
      },
github mfogel / polygon-clipping / bench / bench.js View on Github external
new Benchmark.Suite('Asia union', options)
  .add('mfogel', () => {
    mfogel.union(
      asia.features[0].geometry.coordinates,
      unionPoly.geometry.coordinates
    )
  })
  .add('w8r', () => {
    w8r.union(
      asia.features[0].geometry.coordinates,
      unionPoly.geometry.coordinates
    )
  })
  .run()

const states = load.sync('./bench/fixtures/states_source.geojson')
new Benchmark.Suite('States clip', options)
  .add('mfogel', () => {
    mfogel.union(
      states.features[0].geometry.coordinates,
      states.features[1].geometry.coordinates
    )
  })
  .add('w8r', () => {
    w8r.union(
      states.features[0].geometry.coordinates,
      states.features[1].geometry.coordinates
    )
  })
  .run()
github apifytech / apify-cli / src / lib / secrets.js View on Github external
const getSecretsFile = () => {
    try {
        return loadJson.sync(SECRETS_FILE_PATH) || {};
    } catch (e) {
        return {};
    }
};
github Turfjs / turf / packages / turf-line-overlap / bench.js View on Github external
const fixtures = fs.readdirSync(directory).map(filename => {
    return {
        filename,
        name: path.parse(filename).name,
        geojson: load.sync(directory + filename)
    };
});

load-json-file

Read and parse a JSON file

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis