Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}(`);
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 });
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"
});
}
};
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));
});
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, {
const fixtures = glob.sync(path.join(__dirname, 'test', 'in', '*.geojson')).map(input => {
return {
name: path.parse(input).name,
geojson: load.sync(input)
}
});
fallbackLoader(filepath) {
return this.sync
? loadJsonFile.sync(filepath)
: loadJsonFile(filepath)
}
},
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()
const getSecretsFile = () => {
try {
return loadJson.sync(SECRETS_FILE_PATH) || {};
} catch (e) {
return {};
}
};
const fixtures = fs.readdirSync(directory).map(filename => {
return {
filename,
name: path.parse(filename).name,
geojson: load.sync(directory + filename)
};
});