1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | const bowerConfig = require("bower-config");
|
17 | const fs = require("fs");
|
18 | const path = require("path");
|
19 | function readConfigSync(filename, root) {
|
20 | const configPath = path.resolve(root || '', filename);
|
21 | let config;
|
22 | try {
|
23 | config = fs.readFileSync(configPath, 'utf-8');
|
24 | }
|
25 | catch (e) {
|
26 | return {};
|
27 | }
|
28 | try {
|
29 | return JSON.parse(config);
|
30 | }
|
31 | catch (e) {
|
32 | console.error(`Could not parse ${configPath}`);
|
33 | console.error(e);
|
34 | }
|
35 | return {};
|
36 | }
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | function getPackageName(options) {
|
46 | return options.packageName ||
|
47 | !options.npm && readConfigSync('bower.json', options.root).name ||
|
48 | readConfigSync('package.json', options.root).name ||
|
49 | path.basename(options.root);
|
50 | }
|
51 | exports.getPackageName = getPackageName;
|
52 | function getComponentDir(options) {
|
53 | const root = options.root || process.cwd();
|
54 | const bowerDir = bowerConfig.read(root).directory;
|
55 | return options.componentDir || (options.npm ? 'node_modules' : bowerDir);
|
56 | }
|
57 | exports.getComponentDir = getComponentDir;
|
58 |
|
\ | No newline at end of file |