Skip to content

Commit cf6924e

Browse files
authored
fix: namespaced workspaces create workflows (#28)
1 parent e3eab89 commit cf6924e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/postinstall/copy-content.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ const copyContent = async (path, rootPath, config) => {
8989
// copy and edit workspace repo file (ci github action)
9090
const workspacePkg = (await PackageJson.load(path)).content
9191
const workspaceName = workspacePkg.name
92+
let workspaceFile = `ci-${workspaceName.replace(/\//g, '-')}.yml`
93+
workspaceFile = workspaceFile.replace(/@/g, '')
9294
const workflowPath = join(rootPath, '.github', 'workflows')
9395
await fs.mkdir(workflowPath, {
9496
owner: 'inherit',
@@ -105,7 +107,7 @@ const copyContent = async (path, rootPath, config) => {
105107
workflowData = workflowData.replace(/%%pkgpath%%/g, relPath)
106108
workflowData = workflowData.replace(/%%pkgname%%/g, workspaceName)
107109

108-
await fs.writeFile(join(workflowPath, `ci-${workspaceName}.yml`), workflowData)
110+
await fs.writeFile(join(workflowPath, workspaceFile), workflowData)
109111
}
110112
}
111113
copyContent.moduleFiles = moduleFiles

test/postinstall/copy-content.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ t.test('handles workspaces', async (t) => {
7575
},
7676
b: {
7777
'package.json': JSON.stringify({
78-
name: 'amazingb',
78+
name: '@somenamespace/amazingb',
7979
}),
8080
},
8181
},
@@ -95,6 +95,11 @@ t.test('handles workspaces', async (t) => {
9595
// should have made the workspace action in the root
9696
await t.resolves(fs.stat(join(root, '.github', 'workflows', 'ci-amazinga.yml')))
9797
await t.resolves(fs.stat(join(root, '.github', 'ISSUE_TEMPLATE', 'bug.yml')))
98+
99+
const workspaceb = join(root, 'workspace', 'b')
100+
await copyContent(workspaceb, root, config)
101+
102+
await t.resolves(fs.stat(join(root, '.github', 'workflows', 'ci-somenamespace-amazingb.yml')))
98103
})
99104

100105
t.test('handles workspaces with no root repo files', async (t) => {

0 commit comments

Comments
 (0)