mirror of
https://github.com/Turfjs/turf.git
synced 2025-12-08 20:26:16 +00:00
* Turf as an organization with scoped packages * v3.0.15 * Update readme names * Update readmes * Set uniform package properties * Update readmes, fix GeoJSON interlinks * Fix features and collections * Add public script
43 lines
994 B
JavaScript
Executable File
43 lines
994 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
var fs = require('fs');
|
|
var d3 = require('d3-queue');
|
|
var path = require('path');
|
|
|
|
var q = d3.queue(1);
|
|
|
|
fs.readdirSync('./packages').forEach(function(dir) {
|
|
q.defer(scopePackage, dir);
|
|
});
|
|
|
|
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, callback) {
|
|
var pkgPath = path.join('./packages/', directory, '/package.json');
|
|
var pkg = JSON.parse(fs.readFileSync(pkgPath));
|
|
pkg.name = scopeName(pkg.name);
|
|
pkg.dependencies = objMap(pkg.dependencies || {}, prefixDependency);
|
|
pkg.devDependencies = objMap(pkg.devDependencies || {}, prefixDependency);
|
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
|
callback();
|
|
}
|