Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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);
}
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");
});
});
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`);
});
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);
});
});
map(function(listingItem) {
const { id } = listingItem
return loadJsonFile(path.join(__dirname, './bicycles', `${id}.json`))
}, bicycleListing)
)
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(),
async function loadPkg(file) {
try {
return await loadJsonFile(file);
} catch (_) {
return DEFAULT_PACKAGE;
}
}
const getPackageJson = async (): Promise => {
try {
return await loadJsonFile('package.json');
} catch (err) {
return undefined;
}
};
export default async function getPackageData(base) {
const packagePath = await getPackagePath(base);
return packagePath ? loadJsonFile(packagePath) : {};
}