Skip to content

Commit fd1e727

Browse files
committed
fix(glob hotfix): fix glob patterns starting with ./**/*
Standardise the relative path not to include preceeding ./
1 parent f6fa8b6 commit fd1e727

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/export-functions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,17 @@ export function exportFunctions({
157157
__filename,
158158
exports,
159159
functionDirectoryPath = './',
160-
searchGlob = './**/*.js',
160+
searchGlob = '**/*.js',
161161
funcNameFromRelPath = funcNameFromRelPathDefault,
162162
enableLogger = false,
163163
logger = console,
164164
extractTrigger = getTriggerFromModule,
165165
__dirname,
166166
}: ExportFunctionsConfig) {
167167
const log = enableLogger ? logger : disabledLogger;
168-
const cwd = resolve(__dirname ?? getDirnameFromFilename(__filename), functionDirectoryPath);
169-
168+
const cwd = resolve(__dirname ?? getDirnameFromFilename(__filename), functionDirectoryPath); /* ? */
170169
log.time(dirSearchMsg);
171-
const files = glob.sync(searchGlob, { cwd });
170+
const files = glob.sync(searchGlob, { cwd }); /* ? */
172171
log.timeEnd(dirSearchMsg);
173172

174173
const moduleSearchMsg = `[better-firebase-functions] Search for Module '${getFunctionInstance()}'`;
@@ -177,10 +176,11 @@ export function exportFunctions({
177176

178177
// eslint-disable-next-line no-restricted-syntax
179178
for (const file of files) {
180-
const funcName = funcNameFromRelPath(file); /* ? */
179+
const absPath = resolve(cwd, file);
180+
const standardRelativePath = absPath.substr(cwd.length + 1); /* ? */
181+
const funcName = funcNameFromRelPath(standardRelativePath); /* ? */
181182
if (isDeployment() || funcNameMatchesInstance(funcName)) {
182183
if (!isDeployment()) log.timeEnd(moduleSearchMsg);
183-
const absPath = resolve(cwd, file);
184184
if (absPath.slice(0, -2) === __filename.slice(0, -2)) continue; // Prevent exporting self
185185

186186
if (!isDeployment()) log.time(coldModuleMsg);

0 commit comments

Comments
 (0)