1 | import { resolve } from 'path';
|
2 | import { readFileSync } from 'fs';
|
3 | import { Tags } from './types';
|
4 | export async function guessTargets() {
|
5 | const pkg = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), {
|
6 | encoding: 'utf-8'
|
7 | }));
|
8 | const dependencies = Object.keys(Object.assign({}, pkg.dependencies, pkg.devDependencies));
|
9 | return {
|
10 | [Tags.angular]: isAngular(dependencies),
|
11 | [Tags.react]: isReact(dependencies),
|
12 | [Tags.stencil]: isStencil(dependencies),
|
13 | [Tags.browser]: false,
|
14 | [Tags.node]: false,
|
15 | [Tags.typescript]: isTypescript(dependencies),
|
16 | [Tags.flow]: isFlow(dependencies)
|
17 | };
|
18 | }
|
19 | function isAngular(dependencies) {
|
20 | return dependencies.includes('@angular/core');
|
21 | }
|
22 | function isReact(dependencies) {
|
23 | return dependencies.includes('react');
|
24 | }
|
25 | function isStencil(dependencies) {
|
26 | return dependencies.includes('@stencil/core');
|
27 | }
|
28 | function isTypescript(dependencies) {
|
29 | return dependencies.includes('typescript');
|
30 | }
|
31 | function isFlow(dependencies) {
|
32 | return dependencies.includes('flow');
|
33 | }
|
34 |
|
\ | No newline at end of file |