Skip to content

Commit

Permalink
fix: namespaced workspaces create workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzy committed Jan 6, 2022
1 parent e3eab89 commit e53fe0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/postinstall/copy-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ const copyContent = async (path, rootPath, config) => {
// copy and edit workspace repo file (ci github action)
const workspacePkg = (await PackageJson.load(path)).content
const workspaceName = workspacePkg.name
let workspaceFile = `ci-${workspaceName.replace(/\//g, '-')}.yml`
workspaceFile = workspaceFile.replace(/@/g, '')
const workflowPath = join(rootPath, '.github', 'workflows')
await fs.mkdir(workflowPath, {
owner: 'inherit',
Expand All @@ -105,7 +107,7 @@ const copyContent = async (path, rootPath, config) => {
workflowData = workflowData.replace(/%%pkgpath%%/g, relPath)
workflowData = workflowData.replace(/%%pkgname%%/g, workspaceName)

await fs.writeFile(join(workflowPath, `ci-${workspaceName}.yml`), workflowData)
await fs.writeFile(join(workflowPath, workspaceFile), workflowData)
}
}
copyContent.moduleFiles = moduleFiles
Expand Down
7 changes: 6 additions & 1 deletion test/postinstall/copy-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ t.test('handles workspaces', async (t) => {
},
b: {
'package.json': JSON.stringify({
name: 'amazingb',
name: '@somenamespace/amazingb',
}),
},
},
Expand All @@ -95,6 +95,11 @@ t.test('handles workspaces', async (t) => {
// should have made the workspace action in the root
await t.resolves(fs.stat(join(root, '.github', 'workflows', 'ci-amazinga.yml')))
await t.resolves(fs.stat(join(root, '.github', 'ISSUE_TEMPLATE', 'bug.yml')))

const workspaceb = join(root, 'workspace', 'b')
await copyContent(workspaceb, root, config)

await t.resolves(fs.stat(join(root, '.github', 'workflows', 'ci-somenamespace-amazingb.yml')))
})

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

0 comments on commit e53fe0d

Please sign in to comment.