forked from visgl/react-map-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostinstall.js
34 lines (31 loc) · 995 Bytes
/
postinstall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* eslint-disable */
/**
* NOTE: This is meant to be temporary, until we can figure out a good solution
* for living in a mapbox-gl flow types world.
*/
var flowRemoveTypes = require('flow-remove-types');
var fs = require('fs');
var glob = require('glob');
var MAPBOX_PATHS = [
'../mapbox-gl',
'node_modules/mapbox-gl'
];
function processPathAccess(path, err) {
// Bail if path access errored out. This means the path does not exist
if (err) {
return;
}
// Otherwise run flow remove types on files
glob(path + '/js/**/*.js', {}, function globCallback(err, fileNames) {
for (var i = 0; i < fileNames.length; i++) {
var fileName = fileNames[i];
// This doesn't have to be synchronous(?)
var fileInput = fs.readFileSync(fileName, 'utf8');
fs.writeFileSync(fileName, flowRemoveTypes(fileInput).toString());
}
});
}
MAPBOX_PATHS.forEach(function eachPath(path) {
fs.access(path, processPathAccess.bind(null, path));
});
/* eslint-enable */