Skip to content

Commit

Permalink
Output images as *.ts files, see #1218
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Apr 10, 2022
1 parent 1ce8c7c commit 7f80c2d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion js/grunt/modulify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */';
Expand Down Expand Up @@ -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 ) );
}
};

/**
Expand Down

0 comments on commit 7f80c2d

Please sign in to comment.