From c4ac9e2f3af3eec3c678065180b6df57524f2279 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Wed, 15 Jul 2026 14:58:51 +0100 Subject: [PATCH] fix(skills): ignore line ending differences when checking installed skill Fixes: https://github.com/microsoft/playwright/issues/41760 --- .gitignore | 1 + skillCheck.js | 3 ++- tests/integration.spec.ts | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e5c0047..13a9d15 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules/ /.playwright-cli/ # Ignore self-skill which is a build artifact .claude/skills/playwright-cli/ +.npmrc diff --git a/skillCheck.js b/skillCheck.js index 7f2f441..8c68b96 100644 --- a/skillCheck.js +++ b/skillCheck.js @@ -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; } /** diff --git a/tests/integration.spec.ts b/tests/integration.spec.ts index 9a383dd..37e8e62 100644 --- a/tests/integration.spec.ts +++ b/tests/integration.spec.ts @@ -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'), + })); +});