Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: namespaced workspaces create workflows #28

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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