1 | const resolve = require('path').resolve;
|
2 | const statSync = require('fs').statSync;
|
3 | const readFileSync = require('fs').readFileSync;
|
4 | const configFile = require('./config_file');
|
5 |
|
6 | module.exports = function (root) {
|
7 | if (!root) root = process.cwd();
|
8 |
|
9 | const pkg = JSON.parse(readFileSync(resolve(root, 'package.json')));
|
10 | const config = configFile(root);
|
11 |
|
12 | const buildSourcePatterns = [
|
13 | 'package.json',
|
14 | 'index.js',
|
15 | '{lib,public,server,webpackShims,translations}/**/*',
|
16 | ];
|
17 |
|
18 |
|
19 | ['npm-shrinkwrap.json', 'yarn.lock']
|
20 | .forEach(function (file) {
|
21 | if (fileExists(resolve(root, file))) {
|
22 | buildSourcePatterns.push(file);
|
23 | }
|
24 | });
|
25 |
|
26 | return Object.assign({
|
27 | root: root,
|
28 | kibanaRoot: resolve(root, '../kibana'),
|
29 | serverTestPatterns: ['server/**/__tests__/**/*.js'],
|
30 | buildSourcePatterns: buildSourcePatterns,
|
31 | id: pkg.name,
|
32 | pkg: pkg,
|
33 | version: pkg.version,
|
34 | }, config);
|
35 | };
|
36 |
|
37 | function fileExists(path) {
|
38 | try {
|
39 | const stat = statSync(path);
|
40 | return stat.isFile();
|
41 | } catch (e) {
|
42 | return false;
|
43 | }
|
44 | } |
\ | No newline at end of file |