forked from graphql/graphql.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
39 lines (32 loc) · 1020 Bytes
/
build.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
/**
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
var path = require('path');
var Site = require('./Site');
module.exports = build;
process.on('unhandledRejection', (error, promise) => {
console.error('Unhandled Promise Rejection:');
console.error(error && error.stack || error);
console.error(promise);
});
var pwd = process.env.PWD;
var sourceDir = process.env.npm_package_site_source || './';
var buildDir = process.env.npm_package_site_build || './_build';
var SITE_ROOT = path.resolve(pwd, sourceDir);
var BUILD_ROOT = path.resolve(pwd, buildDir);
async function build(filter) {
console.log('building...');
var site = await Site.readSite(SITE_ROOT);
await Site.buildSite(BUILD_ROOT, site, filter);
console.log('built');
}
if (require.main === module) {
build().catch(error => {
console.error(error.stack || error)
process.exit(1);
});
}