0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 01:11:24 +01:00

use options.name for easier debugging

This commit is contained in:
Rich Harris 2017-02-02 16:25:18 -05:00
parent a1985e592c
commit 9ff9a5921d

View File

@ -9,8 +9,13 @@ import { addLineNumbers, loadConfig, svelte, env, setupHtmlEqual } from './helpe
let showCompiledCode = false;
let compileOptions = null;
function getName ( filename ) {
const base = path.basename( filename ).replace( '.html', '' );
return base[0].toUpperCase() + base.slice( 1 );
}
require.extensions[ '.html' ] = function ( module, filename ) {
const options = Object.assign({ filename }, compileOptions );
const options = Object.assign({ filename, name: getName( filename ) }, compileOptions );
const { code } = svelte.compile( fs.readFileSync( filename, 'utf-8' ), options );
if ( showCompiledCode ) console.log( addLineNumbers( code ) ); // eslint-disable-line no-console