From 7f80c2dc671e8af0e9c45cce823c10224688055b Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Sat, 9 Apr 2022 21:54:44 -0600 Subject: [PATCH] Output images as *.ts files, see https://github.com/phetsims/chipper/issues/1218 --- js/grunt/modulify.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/grunt/modulify.js b/js/grunt/modulify.js index c8146fea5..22e7ac773 100644 --- a/js/grunt/modulify.js +++ b/js/grunt/modulify.js @@ -15,6 +15,8 @@ const grunt = require( 'grunt' ); const loadFileAsDataURI = require( '../common/loadFileAsDataURI' ); const os = require( 'os' ); const getCopyrightLine = require( './getCopyrightLine' ); +const execute = require( '../../../perennial-alias/js/common/execute' ); +const path = require( 'path' ); // disable lint in compiled files, because it increases the linting time const HEADER = '/* eslint-disable */'; @@ -74,7 +76,14 @@ image.onload = unlock; image.src = '${dataURI}'; export default image;`; - fs.writeFileSync( convertSuffix( abspath, '.js' ), fixEOL( contents ) ); + const jsFilePath = convertSuffix( abspath, '.js' ); + const tsFilePath = convertSuffix( abspath, '.ts' ); + if ( fs.existsSync( jsFilePath ) && !fs.existsSync( tsFilePath ) ) { + execute( 'git', [ 'mv', path.basename( jsFilePath ), path.basename( tsFilePath ) ], path.dirname( jsFilePath ) ); + } + else if ( fs.existsSync( tsFilePath ) ) { + fs.writeFileSync( tsFilePath, fixEOL( contents ) ); + } }; /**