mirror of
https://github.com/microsoft/playwright-cli.git
synced 2026-09-14 19:59:39 +08:00
fix(skills): ignore line ending differences when checking installed skill (#439)
Fixes: https://github.com/microsoft/playwright/issues/41760
This commit is contained in:
@@ -4,3 +4,4 @@ node_modules/
|
||||
/.playwright-cli/
|
||||
# Ignore self-skill which is a build artifact
|
||||
.claude/skills/playwright-cli/
|
||||
.npmrc
|
||||
|
||||
+2
-1
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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'),
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user