|
|
|
@ -119,11 +119,12 @@ export abstract class Canonical<T> extends Unit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the suffix that files must have to be loaded by this service.
|
|
|
|
|
* Determines the runtime file extension based on the Node runtime.
|
|
|
|
|
* Returns true if the given file path has the correct suffix to be loaded by this unit.
|
|
|
|
|
*/
|
|
|
|
|
public getScriptSuffix(): string {
|
|
|
|
|
return `${this.suffix}${env('NODE_SCRIPT_SUFFIX', '.js')}`
|
|
|
|
|
public isValidSuffix(path: string): boolean {
|
|
|
|
|
const jsSuffix = `${this.suffix}.js`
|
|
|
|
|
const tsSuffix = `${this.suffix}.ts`
|
|
|
|
|
return path.endsWith(jsSuffix) || path.endsWith(tsSuffix)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -260,7 +261,7 @@ export abstract class Canonical<T> extends Unit {
|
|
|
|
|
public async up(): Promise<void> {
|
|
|
|
|
if ( await this.path.exists() ) {
|
|
|
|
|
for await ( const entry of this.path.walk() ) {
|
|
|
|
|
if ( !entry.endsWith(this.getScriptSuffix()) ) {
|
|
|
|
|
if ( !this.isValidSuffix(entry) ) {
|
|
|
|
|
this.logging.debug(`Skipping file with invalid suffix: ${entry}`)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
@ -305,7 +306,7 @@ export abstract class Canonical<T> extends Unit {
|
|
|
|
|
.split('')
|
|
|
|
|
.reverse()
|
|
|
|
|
.join('')
|
|
|
|
|
.substr(this.getScriptSuffix().length)
|
|
|
|
|
.substr(this.suffix.length + 3) // +3 to account for `.js` or `.ts` ending
|
|
|
|
|
.split('')
|
|
|
|
|
.reverse()
|
|
|
|
|
.join('')
|
|
|
|
|