Skip to content

Commit 75f6015

Browse files
mshanemcclaude
andcommitted
test: enforce Windows path length across all templates
Broaden windowsPathLength guard from project/ templates only to every file under templates/, so any template dir can trip the pack:verify Windows MAX_PATH check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3be71cf commit 75f6015

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

test/utils/windowsPathLength.test.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import * as assert from 'node:assert';
99
import * as fs from 'node:fs';
1010
import * as path from 'node:path';
1111
import {
12-
BUILT_IN_FULL_TEMPLATES,
1312
PLACEHOLDER_KEYS,
1413
WINDOWS_MAX_ALLOWABLE_PATH_LENGTH,
1514
PACKAGE_DIR_PLACEHOLDER,
@@ -63,7 +62,7 @@ const UI_BUNDLE_PLACEHOLDERS: Record<(typeof PLACEHOLDER_KEYS)[number], string>
6362
* pack:verify measures paths under node_modules, e.g. node_modules/@salesforce/templates/lib/...
6463
*/
6564
const PACKAGE_TEMPLATES_PREFIX =
66-
'node_modules/@salesforce/templates/lib/templates/project/';
65+
'node_modules/@salesforce/templates/lib/templates/';
6766

6867
function* walkFiles(dir: string, relativeTo: string): Generator<string> {
6968
if (!fs.existsSync(dir)) {
@@ -107,32 +106,19 @@ describe('Placeholder sync (copy-templates.js ↔ uiBundleTemplateUtils.ts)', ()
107106
});
108107

109108
describe('Windows path length (pack:verify)', () => {
110-
it('project template paths (reactinternalapp, reactexternalapp) stay within Windows max allowable path length', function () {
109+
it('all template files stay within Windows max allowable path length', function () {
111110
const templatesRoot = getTemplateRoot();
112111
if (!templatesRoot) {
113112
this.skip();
114113
return;
115114
}
116115

117-
const projectRoot = path.join(templatesRoot, 'project');
118-
if (!fs.existsSync(projectRoot)) {
119-
this.skip();
120-
return;
121-
}
122-
123116
const longPaths: { length: number; path: string }[] = [];
124117

125-
for (const templateName of BUILT_IN_FULL_TEMPLATES) {
126-
const templateDir = path.join(projectRoot, templateName);
127-
if (!fs.existsSync(templateDir)) {
128-
continue;
129-
}
130-
131-
for (const rel of walkFiles(templateDir, templateDir)) {
132-
const packagePath = PACKAGE_TEMPLATES_PREFIX + templateName + '/' + rel;
133-
if (packagePath.length >= WINDOWS_MAX_ALLOWABLE_PATH_LENGTH) {
134-
longPaths.push({ length: packagePath.length, path: packagePath });
135-
}
118+
for (const rel of walkFiles(templatesRoot, templatesRoot)) {
119+
const packagePath = PACKAGE_TEMPLATES_PREFIX + rel;
120+
if (packagePath.length >= WINDOWS_MAX_ALLOWABLE_PATH_LENGTH) {
121+
longPaths.push({ length: packagePath.length, path: packagePath });
136122
}
137123
}
138124

0 commit comments

Comments
 (0)