-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sudo: false | ||
|
||
language: node_js | ||
|
||
node_js: | ||
- 12 | ||
|
||
before_deploy: | ||
- ./node_modules/.bin/patch-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@fixtures/travis", | ||
"version": "*" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { IsPluginEnabled, Plugin, ResolveConfig } from '#p/types/plugins.js'; | ||
import { _glob } from '#p/util/glob.js'; | ||
import { getDependenciesFromScripts } from '../../util/plugin.js'; | ||
|
||
// https://docs.travis-ci.com/user/customizing-the-build/ | ||
|
||
const title = 'Travis CI'; | ||
|
||
const enablers = 'This plugin is enabled when a `.travis.yml` file is found in the root folder.'; | ||
|
||
const isEnabled: IsPluginEnabled = async ({ cwd }) => Boolean(await _glob({ cwd, patterns: ['.travis.yml'] })); | ||
|
||
const config = ['.travis.yml']; | ||
|
||
const resolveConfig: ResolveConfig = async (config, options) => { | ||
if (!config) return []; | ||
|
||
const beforeDeploy = [config.before_deploy ?? []].flat(); | ||
const beforeInstall = [config.before_install ?? []].flat(); | ||
const beforeScript = [config.before_script ?? []].flat(); | ||
|
||
const scripts = [...beforeDeploy, ...beforeInstall, ...beforeScript]; | ||
|
||
return getDependenciesFromScripts(scripts, { ...options, knownGlobalsOnly: true }); | ||
}; | ||
|
||
export default { | ||
title, | ||
enablers, | ||
isEnabled, | ||
config, | ||
resolveConfig, | ||
} satisfies Plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { test } from 'bun:test'; | ||
import assert from 'node:assert/strict'; | ||
import { main } from '../../src/index.js'; | ||
import { resolve } from '../../src/util/path.js'; | ||
import baseArguments from '../helpers/baseArguments.js'; | ||
import baseCounters from '../helpers/baseCounters.js'; | ||
|
||
const cwd = resolve('fixtures/plugins/travis'); | ||
|
||
test('Find dependencies with the travis plugin', async () => { | ||
const { issues, counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
}); | ||
|
||
assert(issues.binaries['.travis.yml']['patch-version']); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
binaries: 1, | ||
processed: 0, | ||
total: 0, | ||
}); | ||
}); |