UNPKG

1.11 kBJavaScriptView Raw
1const resolve = require('path').resolve;
2const statSync = require('fs').statSync;
3const readFileSync = require('fs').readFileSync;
4const configFile = require('./config_file');
5
6module.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 // add shrinkwrap and lock files, if they exist
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
37function 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