Skip to content

Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.

fix(sync): preserve literal dollar text in generated tables

Rudy Celekli6f0038d64ed8
diff --git a/.github/scripts/sync-skills.js b/.github/scripts/sync-skills.js
index 9d29a76..e13a3f0 100644
--- a/.github/scripts/sync-skills.js
+++ b/.github/scripts/sync-skills.js
@@ -123,7 +123,7 @@ function updateReadme(skills) {
return false;
}
- const newContent = content.replace(tableRegex, `$1${newTable}$2`);
+ const newContent = content.replace(tableRegex, (_match, start, end) => start + newTable + end);
if (newContent === content) {
return false;
diff --git a/tests/clis/sync-literal-text.test.cjs b/tests/clis/sync-literal-text.test.cjs
new file mode 100644
index 0000000..7be82da
--- /dev/null
+++ b/tests/clis/sync-literal-text.test.cjs
@@ -0,0 +1,30 @@
+const { test } = require('node:test')
+const assert = require('node:assert/strict')
+const { spawnSync } = require('node:child_process')
+const { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync } = require('node:fs')
+const { tmpdir } = require('node:os')
+const path = require('node:path')
+const script = path.resolve(__dirname, '../../.github/scripts/sync-skills.js')
+
+function sync(description) {
+ const root = mkdtempSync(path.join(tmpdir(), 'marketing-sync-literal-'))
+ try {
+ mkdirSync(path.join(root, 'skills/example'), { recursive: true })
+ mkdirSync(path.join(root, '.claude-plugin'))
+ writeFileSync(path.join(root, 'skills/example/SKILL.md'), `---\nname: example\ndescription: ${description}\nmetadata:\n version: "1.0.0"\n---\n`)
+ writeFileSync(path.join(root, '.claude-plugin/marketplace.json'), JSON.stringify({ metadata: { version: '1.0.0' }, plugins: [{ description: '1 marketing skills' }] }))
+ writeFileSync(path.join(root, '.claude-plugin/plugin.json'), JSON.stringify({ version: '1.0.0' }))
+ writeFileSync(path.join(root, 'README.md'), 'Before table\n<!-- SKILLS:START -->\nold table\n<!-- SKILLS:END -->\nAfter table\n')
+ const result = spawnSync(process.execPath, [script], { cwd: root, encoding: 'utf8', timeout: 10000 })
+ assert.equal(result.status, 0, result.stderr)
+ return readFileSync(path.join(root, 'README.md'), 'utf8')
+ } finally {
+ rmSync(root, { recursive: true, force: true })
+ }
+}
+
+for (const description of ['Use when testing $1 and $2 offers.', 'Use when explaining the literal $& replacement token.', "Use when comparing $` and $' JavaScript tokens.", 'Use when testing ordinary offers.']) {
+ test(`sync preserves literal description: ${description}`, () => {
+ assert.equal(sync(description), `Before table\n<!-- SKILLS:START -->\n| Skill | Description |\n|-------|-------------|\n| [example](skills/example/) | ${description} |\n<!-- SKILLS:END -->\nAfter table\n`)
+ })
+}