@@ -650,8 +650,8 @@ exports.main = function main(argv, options, callback) {
650
650
651
651
// Try file.ext, file/index.ext, file.d.ext
652
652
if ( ! internalPath . startsWith ( libraryPrefix ) ) {
653
- if ( ( sourceText = readFile ( sourcePath = internalPath + extension . ext , baseDir ) ) == null ) {
654
- if ( ( sourceText = readFile ( sourcePath = internalPath + "/index" + extension . ext , baseDir ) ) == null ) {
653
+ if ( ! ( sourceText = readFile ( sourcePath = internalPath + extension . ext , baseDir ) ) ) {
654
+ if ( ! ( sourceText = readFile ( sourcePath = internalPath + "/index" + extension . ext , baseDir ) ) ) {
655
655
// portable d.ext: uses the .js file next to it in JS or becomes an import in Wasm
656
656
sourcePath = internalPath + extension . ext ;
657
657
sourceText = readFile ( internalPath + extension . ext_d , baseDir ) ;
@@ -670,17 +670,17 @@ exports.main = function main(argv, options, callback) {
670
670
sourcePath = libraryPrefix + indexName + extension . ext ;
671
671
} else { // custom lib dirs
672
672
for ( const libDir of customLibDirs ) {
673
- if ( ( sourceText = readFile ( plainName + extension . ext , libDir ) ) != null ) {
673
+ if ( ( sourceText = readFile ( plainName + extension . ext , libDir ) ) ) {
674
674
sourcePath = libraryPrefix + plainName + extension . ext ;
675
675
break ;
676
676
} else {
677
- if ( ( sourceText = readFile ( indexName + extension . ext , libDir ) ) != null ) {
677
+ if ( ( sourceText = readFile ( indexName + extension . ext , libDir ) ) ) {
678
678
sourcePath = libraryPrefix + indexName + extension . ext ;
679
679
break ;
680
680
}
681
681
}
682
682
}
683
- if ( sourceText == null ) { // paths
683
+ if ( ! sourceText ) { // paths
684
684
const match = internalPath . match ( / ^ ~ l i b \/ ( (?: @ [ ^ / ] + \/ ) ? [ ^ / ] + ) (?: \/ ( .+ ) ) ? / ) ; // ~lib/(pkg)/(path), ~lib/(@org/pkg)/(path)
685
685
if ( match ) {
686
686
const packageName = match [ 1 ] ;
@@ -722,7 +722,7 @@ exports.main = function main(argv, options, callback) {
722
722
}
723
723
const mainDir = path . join ( currentPath , packageName , mainPath ) ;
724
724
const plainName = filePath ;
725
- if ( ( sourceText = readFile ( path . join ( mainDir , plainName + extension . ext ) , baseDir ) ) != null ) {
725
+ if ( ( sourceText = readFile ( path . join ( mainDir , plainName + extension . ext ) , baseDir ) ) ) {
726
726
sourcePath = `${ libraryPrefix } ${ packageName } /${ plainName } ${ extension . ext } ` ;
727
727
packageBases . set ( sourcePath . replace ( extension . re , "" ) , path . join ( currentPath , packageName ) ) ;
728
728
if ( opts . traceResolution ) {
@@ -731,7 +731,7 @@ exports.main = function main(argv, options, callback) {
731
731
break ;
732
732
} else if ( ! isPackageRoot ) {
733
733
const indexName = `${ filePath } /index` ;
734
- if ( ( sourceText = readFile ( path . join ( mainDir , indexName + extension . ext ) , baseDir ) ) !== null ) {
734
+ if ( ( sourceText = readFile ( path . join ( mainDir , indexName + extension . ext ) , baseDir ) ) ) {
735
735
sourcePath = `${ libraryPrefix } ${ packageName } /${ indexName } ${ extension . ext } ` ;
736
736
packageBases . set ( sourcePath . replace ( extension . re , "" ) , path . join ( currentPath , packageName ) ) ;
737
737
if ( opts . traceResolution ) {
@@ -746,7 +746,7 @@ exports.main = function main(argv, options, callback) {
746
746
}
747
747
}
748
748
// No such file
749
- if ( sourceText == null ) return null ;
749
+ if ( ! sourceText ) return null ;
750
750
return { sourceText, sourcePath } ;
751
751
}
752
752
@@ -784,10 +784,10 @@ exports.main = function main(argv, options, callback) {
784
784
let runtimeName = String ( opts . runtime ) ;
785
785
let runtimePath = `rt/index-${ runtimeName } ` ;
786
786
let runtimeText = exports . libraryFiles [ runtimePath ] ;
787
- if ( runtimeText == null ) {
787
+ if ( ! runtimeText ) {
788
788
runtimePath = runtimeName ;
789
789
runtimeText = readFile ( runtimePath + extension . ext , baseDir ) ;
790
- if ( runtimeText == null ) return callback ( Error ( `Runtime '${ runtimeName } ' not found.` ) ) ;
790
+ if ( ! runtimeText ) return callback ( Error ( `Runtime '${ runtimeName } ' not found.` ) ) ;
791
791
} else {
792
792
runtimePath = `~lib/${ runtimePath } ` ;
793
793
}
@@ -814,14 +814,15 @@ exports.main = function main(argv, options, callback) {
814
814
: sourcePath ;
815
815
816
816
// Try entryPath.ext, then entryPath/index.ext
817
- let sourceText = readFile ( sourcePath + extension . ext , baseDir ) ;
818
- if ( sourceText == null ) {
819
- const path = `${ sourcePath } /index${ extension . ext } ` ;
820
- sourceText = readFile ( path , baseDir ) ;
821
- if ( sourceText != null ) sourcePath = path ;
822
- else sourcePath += extension . ext ;
817
+ let sourcePathWithExt = sourcePath + extension . ext ;
818
+ let sourceText = readFile ( sourcePathWithExt , baseDir ) ;
819
+ if ( ! sourceText ) {
820
+ const indexPathWithExt = `${ sourcePath } /index${ extension . ext } ` ;
821
+ sourceText = readFile ( indexPathWithExt , baseDir ) ;
822
+ if ( sourceText ) sourcePath = indexPathWithExt ;
823
+ else sourcePath = sourcePathWithExt ;
823
824
} else {
824
- sourcePath += extension . ext ;
825
+ sourcePath = sourcePathWithExt ;
825
826
}
826
827
827
828
stats . parseCount ++ ;
@@ -1058,7 +1059,7 @@ exports.main = function main(argv, options, callback) {
1058
1059
let contents = [ ] ;
1059
1060
map . sources . forEach ( ( name , index ) => {
1060
1061
let text = assemblyscript . getSource ( program , __newString ( name . replace ( extension . re , "" ) ) ) ;
1061
- if ( text == null ) return callback ( Error ( `Source of file '${ name } ' not found.` ) ) ;
1062
+ if ( ! text ) return callback ( Error ( `Source of file '${ name } ' not found.` ) ) ;
1062
1063
contents [ index ] = text ;
1063
1064
} ) ;
1064
1065
map . sourcesContent = contents ;
0 commit comments