fix(skills): ignore line ending differences when checking installed skill (#439)

Fixes: https://github.com/microsoft/playwright/issues/41760
This commit is contained in:
Dmitry Gozman
2026-07-15 17:22:37 +01:00
committed by GitHub
parent 793cfb3257
commit eee5a185c9
3 changed files with 16 additions and 1 deletions
+1
View File
@@ -4,3 +4,4 @@ node_modules/
/.playwright-cli/
# Ignore self-skill which is a build artifact
.claude/skills/playwright-cli/
.npmrc
+2 -1
View File
@@ -37,7 +37,8 @@ function installedSkillTargets() {
* @returns
*/
function readSkill(file) {
return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : null;
// Normalize line endings, they could be affected by git or editor settings.
return fs.existsSync(file) ? fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n') : null;
}
/**
+13
View File
@@ -84,3 +84,16 @@ test('warns when installed skill is out of date', async ({}) => {
error: expect.stringContaining('does not match the tool version'),
}));
});
test('does not warn when installed skill only differs in line endings', async ({}) => {
expect(await runCli('install', '--skills')).toEqual(expect.objectContaining({
exitCode: 0,
}));
const skillFile = path.join(test.info().outputPath(), '.claude', 'skills', 'playwright-cli', 'SKILL.md');
fs.writeFileSync(skillFile, fs.readFileSync(skillFile, 'utf8').replace(/\n/g, '\r\n'));
expect(await runCli('--help')).toEqual(expect.objectContaining({
error: expect.not.stringContaining('does not match the tool version'),
}));
});