UNPKG

1.11 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.getRandomNumber = getRandomNumber;
7exports.getNpmErrorMessage = getNpmErrorMessage;
8function getRandomNumber(min, max) {
9 return Math.floor(Math.random() * (max - min)) + min;
10}
11
12var TICK = exports.TICK = '✓';
13var CONFIG_FILE_NAME = exports.CONFIG_FILE_NAME = '.motion.json';
14var CONFIG_FILE_DEFAULT = exports.CONFIG_FILE_DEFAULT = {
15 babel: {
16 plugins: [],
17 presets: ['babel-preset-steelbrain']
18 },
19 pundle: {
20 presets: [],
21 components: []
22 },
23 pathType: 'filePath',
24 saveNpmModules: true,
25 get webServerPort() {
26 return getRandomNumber(8000, 15000);
27 },
28 outputDirectory: './dist'
29};
30var CONFIG_FILE_OPTIONS = exports.CONFIG_FILE_OPTIONS = {
31 prettyPrint: true,
32 createIfNonExistent: false
33};
34
35var NPM_ERROR_EXTRACTION_REGEX = /npm ERR! code .*?\n\nnpm ERR! .*? (.*)/gm;
36function getNpmErrorMessage(contents) {
37 if (!contents.includes('npm ERR!')) {
38 return contents;
39 }
40 var match = NPM_ERROR_EXTRACTION_REGEX.exec(contents);
41 if (match) {
42 return match[1];
43 }
44 return contents;
45}
\No newline at end of file