11#!/usr/bin/env node
22
3- import { createRequire } from 'node:module ' ;
3+ import { loadTemplates , cli } from '../lib/precompiler.js ' ;
44import yargs from 'yargs' ;
55
6- const require = createRequire ( import . meta. url ) ;
7- const Precompiler = require ( '../dist/cjs/precompiler' ) ;
8-
96const parser = yargs ( process . argv . slice ( 2 ) )
107 . usage ( 'Precompile handlebar templates.\nUsage: $0 [template|directory]...' )
118 . help ( false )
@@ -19,23 +16,6 @@ const parser = yargs(process.argv.slice(2))
1916 type : 'string' ,
2017 description : 'Source Map File' ,
2118 } )
22- . option ( 'a' , {
23- type : 'boolean' ,
24- description : 'Exports amd style (require.js)' ,
25- alias : 'amd' ,
26- } )
27- . option ( 'c' , {
28- type : 'string' ,
29- description : 'Exports CommonJS style, path to Handlebars module' ,
30- alias : 'commonjs' ,
31- default : null ,
32- } )
33- . option ( 'h' , {
34- type : 'string' ,
35- description : 'Path to handlebar.js (only valid for amd-style)' ,
36- alias : 'handlebarPath' ,
37- default : '' ,
38- } )
3919 . option ( 'k' , {
4020 type : 'string' ,
4121 description : 'Known helpers' ,
@@ -117,7 +97,7 @@ const argv = parser.parseSync();
11797argv . files = argv . _ ;
11898delete argv . _ ;
11999
120- Precompiler . loadTemplates ( argv , function ( err , opts ) {
100+ loadTemplates ( argv , function ( err , opts ) {
121101 if ( err ) {
122102 throw err ;
123103 }
@@ -127,7 +107,7 @@ Precompiler.loadTemplates(argv, function (err, opts) {
127107 } else {
128108 // cli() is async (returns a Promise), so errors would become unhandled
129109 // rejections. Re-throw via nextTick to surface them as uncaught exceptions.
130- Promise . resolve ( Precompiler . cli ( opts ) ) . catch ( ( error ) => {
110+ Promise . resolve ( cli ( opts ) ) . catch ( ( error ) => {
131111 process . nextTick ( ( ) => {
132112 throw error ;
133113 } ) ;
0 commit comments