forked from ngageoint/opensphere-build-resolver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolve.js
executable file
·47 lines (38 loc) · 1.22 KB
/
resolve.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
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
'use strict';
if (!Object.values) {
require('object.values').shim();
}
const Promise = require('bluebird');
const pluginUtils = require('./plugins');
const core = require('./core');
const path = require('path');
var thisPackage = require(path.resolve(process.cwd(), 'package'));
if (!thisPackage.build) {
console.error('This project does not appear to be an OpenSphere Closure ' +
'Build project. Are you running this from the wrong directory?');
process.exit(1);
}
if (process.argv.length < 3 || !process.argv[2]) {
console.error('Please provide the output directory as an argument');
process.exit(1);
}
var plugins = pluginUtils.load();
var outputDir = path.resolve(process.cwd(), process.argv[2]);
core.resolvePackage(undefined, undefined, process.cwd(), 0, undefined, plugins)
.then(function() {
console.log();
return Promise.map(plugins.postResolvers, function(post) {
return post(thisPackage, outputDir);
});
})
.then(function() {
return Promise.map(plugins.writers, function(writer) {
return writer(thisPackage, outputDir);
});
})
.catch(function(e) {
console.error('There was an error resolving');
console.error(e);
process.exit(1);
});