Skip to content

Commit d8af668

Browse files
committed
refactor(loadDefaultScripts): better filter property
1 parent 61a9180 commit d8af668

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/const.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const metaEndTerm = '**/';
2323
// │ Script │
2424
// └ ┘
2525

26+
export const SCRIPT_EXTENSION = /\.js$/g;
2627
export const MAIN_FUNCTION_EXEC = 'main(this)';
2728

2829
// ┌ ┐

src/scriptManager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
defaultScriptPath,
77
metaEndTerm,
88
metaStartTerm,
9-
NOTIFY
9+
NOTIFY,
10+
SCRIPT_EXTENSION
1011
} from './const.js';
1112
import { matchesMetas, stringRange } from './utils/utils.js';
1213
import { ScriptExecution } from './models/ScriptExecution.js';
@@ -28,7 +29,7 @@ export class ScriptManager {
2829
loadDefaultScripts() {
2930
let scriptsFilenames = fs
3031
.readdirSync(defaultScriptPath)
31-
.filter(file => file.includes('.js'));
32+
.filter(file => file.match(SCRIPT_EXTENSION));
3233

3334
scriptsFilenames.forEach(filename => {
3435
this.loadScript(path.join(defaultScriptPath, filename));

0 commit comments

Comments
 (0)