File tree Expand file tree Collapse file tree 4 files changed +19
-9
lines changed
Expand file tree Collapse file tree 4 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 1- export const JS = {
2- id : 'js' ,
1+ import { IBoilerplate } from '.' ;
2+
3+ export const JS : IBoilerplate = {
34 extension : '.js' ,
4- condition : ' .jsx?$' ,
5+ condition : p => / \ .j s x ? $ / . test ( p ) ,
56 code : `
67import React from 'react';
78import { render } from 'react-dom';
@@ -13,21 +14,19 @@ export default function(module) {
1314` ,
1415} ;
1516
16- export const HTML = {
17- id : 'html' ,
17+ export const HTML : IBoilerplate = {
1818 extension : '.html' ,
19- condition : '.html$' ,
19+ condition : p => p . endsWith ( '.html' ) ,
2020 code : `
2121export default function(module) {
2222 document.body.innerHTML = module
2323}
2424` ,
2525} ;
2626
27- export const TS = {
28- id : 'ts' ,
27+ export const TS : IBoilerplate = {
2928 extension : '.ts' ,
30- condition : ' .tsx?$' ,
29+ condition : p => / \ .t s x ? $ / . test ( p ) ,
3130 code : `
3231import * as React from 'react';
3332import { render } from 'react-dom';
Original file line number Diff line number Diff line change 11import { getCurrentManager } from '../compile' ;
22
3+ export interface IBoilerplate {
4+ extension : string ;
5+ condition : ( path : string ) => boolean ;
6+ code : string ;
7+ /**
8+ * Normally we only execute boilerplates in module mode. By setting this to true we will
9+ * execute the boilerplate in any mode.
10+ */
11+ enabledByDefault ?: boolean ;
12+ }
13+
314let cachedBoilerplates = [ ] ;
415
516export async function evalBoilerplates ( boilerplates ) {
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments