diff --git a/lib/content/ci-no-windows.yml b/lib/content/ci-no-windows.yml new file mode 100644 index 00000000..438b7686 --- /dev/null +++ b/lib/content/ci-no-windows.yml @@ -0,0 +1,48 @@ +# This file is automatically added by @npmcli/template-oss. Do not edit. + +name: CI + +on: + pull_request: + push: + branches: + - main + - latest + schedule: + # "At 02:00 on Monday" https://crontab.guru/#0_1_*_*_1 + - cron: "0 2 * * 1" + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '16' + - run: npm i --prefer-online -g npm@latest + - run: npm i + - run: npm run lint + + test: + strategy: + fail-fast: false + matrix: + node-version: [12.13.0, 12.x, 14.15.0, 14.x, 16.13.0, 16.x] + platform: + - os: ubuntu-latest + shell: bash + - os: macos-latest + shell: bash + runs-on: ${{ matrix.platform.os }} + defaults: + run: + shell: ${{ matrix.platform.shell }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: npm i --prefer-online -g npm@latest + - run: npm i + - run: npm test --ignore-scripts diff --git a/lib/postinstall/copy-content.js b/lib/postinstall/copy-content.js index c90a284e..a9db8294 100644 --- a/lib/postinstall/copy-content.js +++ b/lib/postinstall/copy-content.js @@ -38,6 +38,7 @@ const defaultConfig = { applyRootRepoFiles: true, applyWorkspaceRepoFiles: true, applyRootModuleFiles: true, + windowsCI: true, } const copyFiles = async (targetDir, files) => { @@ -78,9 +79,15 @@ const copyContent = async (path, rootPath, config) => { if (!isWorkspace) { if (config.applyRootRepoFiles) { await copyFiles(rootPath, repoFiles) + if (!config.windowsCI) { + // copyFiles already did the mkdir so we can just fs.copyFile now + await fs.copyFile(join(contentDir, 'ci-no-windows.yml'), join(rootPath, 'ci.yml')) + } } return - } // only workspace now + } + + // only workspace now // TODO: await copyFiles(path, workspaceFiles) // if we ever have workspace specific files diff --git a/test/postinstall/copy-content.js b/test/postinstall/copy-content.js index cc17c9b4..5c708278 100644 --- a/test/postinstall/copy-content.js +++ b/test/postinstall/copy-content.js @@ -225,3 +225,20 @@ t.test('handles workspaces with no root files', async (t) => { await t.rejects(fs.stat(join(root, '.github', 'workflows', 'ci-amazinga.yml'))) await t.rejects(fs.stat(join(root, '.github', 'ISSUE_TEMPLATE', 'bug.yml'))) }) + +t.test('no windows ci', async (t) => { + const pkgWithNoWindowsCI = { + 'package.json': JSON.stringify({ + name: 'testpkg', + templateOSS: { + windowsCI: false, + }, + }), + } + const root = t.testdir(pkgWithNoWindowsCI) + const config = await getConfig(root) + await copyContent(root, root, config) + const target = join(root, 'ci.yml') + const contents = await fs.readFile(target, 'utf8') + await t.notMatch(/windows/, contents, 'no windows ci') +})