@@ -90,7 +90,7 @@ function writeFileSync(p: string, content: string) {
9090/**
9191 * Main entrypoint.
9292 */
93- function main ( ) {
93+ export function main ( ) {
9494 // find all packages (including packages in nested node_modules)
9595 const pkgs = findPackages ( ) ;
9696
@@ -104,12 +104,6 @@ function main() {
104104 generateBuildFiles ( pkgs )
105105}
106106
107- module . exports = {
108- main,
109- printPackageBin,
110- printIndexBzl,
111- } ;
112-
113107/**
114108 * Generates all build files
115109 */
@@ -515,11 +509,13 @@ function findScopes() {
515509 * package json and return it as an object along with
516510 * some additional internal attributes prefixed with '_'.
517511 */
518- function parsePackage ( p : string , hide : boolean = true ) : Dep {
512+ export function parsePackage ( p : string , hide : boolean = true ) : Dep {
519513 // Parse the package.json file of this package
520514 const packageJson = path . posix . join ( p , 'package.json' ) ;
521- const pkg = isFile ( packageJson ) ? JSON . parse ( fs . readFileSync ( packageJson , { encoding : 'utf8' } ) ) :
522- { version : '0.0.0' } ;
515+ const stripBom = ( s : string ) => s . charCodeAt ( 0 ) === 0xFEFF ? s . slice ( 1 ) : s ;
516+ const pkg = isFile ( packageJson ) ?
517+ JSON . parse ( stripBom ( fs . readFileSync ( packageJson , { encoding : 'utf8' } ) ) ) :
518+ { version : '0.0.0' } ;
523519
524520 // Trim the leading node_modules from the path and
525521 // assign to _dir for future use
@@ -1031,7 +1027,7 @@ function additionalAttributes(pkg: Dep, name: string) {
10311027/**
10321028 * Given a pkg, return the skylark nodejs_binary targets for the package.
10331029 */
1034- function printPackageBin ( pkg : Dep ) {
1030+ export function printPackageBin ( pkg : Dep ) {
10351031 let result = '' ;
10361032 const executables = _findExecutables ( pkg ) ;
10371033 if ( executables . size ) {
@@ -1058,7 +1054,7 @@ nodejs_binary(
10581054 return result ;
10591055}
10601056
1061- function printIndexBzl ( pkg : Dep ) {
1057+ export function printIndexBzl ( pkg : Dep ) {
10621058 let result = '' ;
10631059 const executables = _findExecutables ( pkg ) ;
10641060 if ( executables . size ) {
0 commit comments