File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
packages/common/src/templates Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 1-
21import { absolute } from '../utils/path' ;
32import {
43 ConfigurationFile ,
@@ -118,15 +117,31 @@ export default class Template {
118117 this . showCube = options . showCube != null ? options . showCube : true ;
119118 }
120119
120+ private getMainFromPackage ( pkg : {
121+ main ?: string [ ] | string ;
122+ } ) : string | undefined {
123+ try {
124+ if ( ! pkg . main ) {
125+ return undefined ;
126+ }
127+
128+ if ( Array . isArray ( pkg . main ) ) {
129+ return absolute ( pkg . main [ 0 ] ) ;
130+ }
131+
132+ if ( typeof pkg . main === 'string' ) {
133+ return absolute ( pkg . main ) ;
134+ }
135+ } catch ( e ) { }
136+ }
137+
121138 /**
122139 * Get possible entry files to evaluate, differs per template
123140 */
124141 getEntries ( configurationFiles : ParsedConfigurationFiles ) : Array < string > {
125142 return [
126143 configurationFiles . package &&
127- configurationFiles . package . parsed &&
128- configurationFiles . package . parsed . main &&
129- absolute ( configurationFiles . package . parsed . main ) ,
144+ this . getMainFromPackage ( configurationFiles . package . parsed ) ,
130145 '/index.' + ( this . isTypescript ? 'ts' : 'js' ) ,
131146 '/src/index.' + ( this . isTypescript ? 'ts' : 'js' ) ,
132147 '/src/index.ts' ,
You can’t perform that action at this time.
0 commit comments