diff --git a/generators/src/filepaths.ts b/generators/src/filepaths.ts index 2542d2df..347f0802 100644 --- a/generators/src/filepaths.ts +++ b/generators/src/filepaths.ts @@ -140,6 +140,8 @@ function filepathsFn(options: FilepathsOptions = {}): Fig.Generator { }; return { + [Symbol.generatorTag]: "filepathsTemplate", + trigger: (oldToken, newToken) => { const oldLastSlashIndex = oldToken.lastIndexOf("/"); const newLastSlashIndex = newToken.lastIndexOf("/"); @@ -189,8 +191,12 @@ function filepathsFn(options: FilepathsOptions = {}): Fig.Generator { }; } -export const folders = Object.assign( - () => filepathsFn({ showFolders: "only" }), - Object.freeze(filepathsFn({ showFolders: "only" })) -); +function foldersFn(): Fig.Generator { + return { + ...filepathsFn({ showFolders: "only" }), + [Symbol.generatorTag]: "foldersTemplate", + }; +} + +export const folders = Object.assign(foldersFn, Object.freeze(foldersFn())); export const filepaths = Object.assign(filepathsFn, Object.freeze(filepathsFn())); diff --git a/types/docs.json b/types/docs.json index 8f3c3273..7180289e 100644 --- a/types/docs.json +++ b/types/docs.json @@ -1069,6 +1069,16 @@ "hasDocComment": true, "extends": [], "members": [ + { + "name": "[Symbol.generatorTag]", + "excluded": true, + "summary": "Assign a tag to generators so we can identify them", + "parameters": [], + "optional": true, + "declaration": "[Symbol.generatorTag]?: string", + "examples": [], + "hasDocComment": true + }, { "name": "template", "excluded": false, @@ -1243,6 +1253,23 @@ } ], "inheritedMembers": [] + }, + { + "name": "SymbolConstructor", + "hasDocComment": false, + "extends": [], + "members": [ + { + "name": "generatorTag", + "excluded": false, + "parameters": [], + "optional": false, + "declaration": "readonly generatorTag: unique symbol", + "examples": [], + "hasDocComment": false + } + ], + "inheritedMembers": [] } ], "typeAliases": [ diff --git a/types/index.d.ts b/types/index.d.ts index cfaac24f..d9df90e4 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1032,6 +1032,11 @@ declare namespace Fig { * */ interface Generator { + /** + * Assign a tag to generators so we can identify them + * @excluded + */ + [Symbol.generatorTag]?: string; /** * A template which is a single `TemplateString` or an array of `TemplateStrings`. * @@ -1211,3 +1216,7 @@ declare namespace Fig { cache?: Cache; } } + +interface SymbolConstructor { + readonly generatorTag: unique symbol; +}