turf/scripts/set-uniforms

46 lines
1.2 KiB
JavaScript
Executable File

#!/usr/bin/env node
var fs = require("fs");
var path = require("path");
var license = fs.readFileSync("./LICENSE", "utf8");
fs.readdirSync("./packages").forEach(scopePackage);
fs.readdirSync("./packages").forEach(writeLicense);
function scopeName(name) {
if (name.match(/^turf/)) {
return "@" + name.replace(/-/, "/");
} else {
return name;
}
}
function objMap(obj, map) {
var newObj = {};
for (var k in obj) {
var res = map([ k, obj[k] ]);
newObj[res[(0)]] = res[(1)];
}
return newObj;
}
function prefixDependency(kv) {
return [ scopeName(kv[(0)]), kv[(1)] ];
}
function scopePackage(directory) {
var pkgPath = path.join("./packages/", directory, "/package.json");
var pkg = JSON.parse(fs.readFileSync(pkgPath));
pkg.homepage = "https://github.com/Turfjs/turf";
pkg.bugs = { url: "https://github.com/Turfjs/turf/issues" };
pkg.license = "MIT";
pkg.author = "Turf Authors";
pkg.repository = { type: "git", url: "git://github.com/Turfjs/turf.git" };
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
}
function writeLicense(directory) {
var licensePath = path.join("./packages/", directory, "/LICENSE");
fs.writeFileSync(licensePath, license);
}