How to use the load-json-file 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 webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / installResolver / install.js View on Github external
}

    const { step } = args;

    try {
        if (!installation.stepAvailable(step)) {
            return new ErrorResponse({
                code: "PB_INSTALL_ABORTED",
                message: `Installation step ${step} not available or already executed.`
            });
        }

        if (step === 1) {
            // /tmp/installation-files/apiPageBuilder/data/categoriesData.json'","
            const INSTALL_EXTRACT_DIR = await downloadInstallationFiles();
            const categoriesData = await loadJson(
                path.join(INSTALL_EXTRACT_DIR, "data/categoriesData.json")
            );
            installation.getStep(1).markAsStarted();
            const staticPageCount = await PbCategory.count({ query: { slug: "static" } });
            if (staticPageCount === 0) {
                for (let i = 0; i < categoriesData.length; i++) {
                    const instance = new PbCategory();
                    await instance.populate(categoriesData[i]).save();
                }
            }

            installation.getStep(1).markAsCompleted();
            await settings.save();
            return new Response(true);
        }
github lerna / lerna / test / Command.js View on Github external
it("is set from lerna.json config", async () => {
        const lernaJsonLocation = path.join(testDir, "lerna.json");
        const lernaConfig = await loadJsonFile(lernaJsonLocation);
        lernaConfig.loglevel = "warn";
        await writeJsonFile(lernaJsonLocation, lernaConfig, { indent: 2 });

        const ok = new OkCommand([], {}, testDir);
        await ok.run();

        expect(log.level).toBe("warn");
      });
    });
github zeit / now / test / unit.js View on Github external
test('`now.files` overrides `.gitignore` in Docker', async t => {
  const path = 'now-json-docker-gitignore-override';
  let files = await getDockerFiles(
    fixture(path),
    await loadJSON(getLocalConfigPath(fixture(path)))
  );
  files = files.sort(alpha);

  t.is(files.length, 5);
  t.is(base(files[0]), `${path}/Dockerfile`);
  t.is(base(files[1]), `${path}/a.js`);
  t.is(base(files[2]), `${path}/b.js`);
  t.is(base(files[3]), `${path}/build/a/c.js`);
  t.is(base(files[4]), `${path}/now.json`);
});
github lerna / lerna / test / Command.js View on Github external
it("should be added to the instance", async () => {
      const command = new Command([], {});
      const { version } = await loadJsonFile(path.resolve(__dirname, "../package.json"));
      expect(command.lernaVersion).toEqual(version);
    });
  });
github illarionvk / demo-wizard-state-machine / public / data / test-bicycles.js View on Github external
map(function(listingItem) {
        const { id } = listingItem

        return loadJsonFile(path.join(__dirname, './bicycles', `${id}.json`))
      }, bicycleListing)
    )
github Azure / BatchExplorer / app / services / ncj-template.service.ts View on Github external
flatMap(() => {
                const promise = loadJsonFile(this.githubDataService.getLocalPath(uri)).then((json) => {
                    return json;
                }).catch((error) => {
                    log.error(`File is not valid json: ${error.message}`);
                });

                return from(promise);
            }),
            share(),
github xojs / atom-linter-xo / lib / get-package-path.js View on Github external
async function loadPkg(file) {
	try {
		return await loadJsonFile(file);
	} catch (_) {
		return DEFAULT_PACKAGE;
	}
}
github Oluwasegun-AA / md-generator / src / projectEnv / utils.ts View on Github external
const getPackageJson = async (): Promise => {
  try {
    return await loadJsonFile('package.json');
  } catch (err) {
    return undefined;
  }
};
github xojs / atom-linter-xo / lib / get-package-data.js View on Github external
export default async function getPackageData(base) {
	const packagePath = await getPackagePath(base);
	return packagePath ? loadJsonFile(packagePath) : {};
}

load-json-file

Read and parse a JSON file

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis