Skip to content
This repository was archived by the owner on May 17, 2022. It is now read-only.

Commit 33da70a

Browse files
committed
feat(config): difined the travis config file
1 parent c54b37d commit 33da70a

File tree

7 files changed

+124
-11
lines changed

7 files changed

+124
-11
lines changed

package-lock.json

+51-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,8 @@
5252
"rollup-plugin-auto-external": "^2.0.0",
5353
"sinon": "^7.3.0",
5454
"travis-lint": "^1.0.0"
55+
},
56+
"dependencies": {
57+
"write-yaml": "^1.0.0"
5558
}
5659
}

src/config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import writeYaml from '../third-party-wrappers/write-yaml';
2+
3+
export default function ({projectRoot}) {
4+
return writeYaml(
5+
`${projectRoot}/.travis.yml`,
6+
{language: 'generic', notifications: {email: false}, install: 'bpkg getdeps', script: 'make test'}
7+
);
8+
}

src/scaffolder.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
export default function () {
1+
import scaffoldConfig from './config';
2+
3+
export default async function ({projectRoot}) {
4+
await scaffoldConfig({projectRoot});
5+
26
return {};
37
}

test/unit/config-test.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import sinon from 'sinon';
2+
import {assert} from 'chai';
3+
import any from '@travi/any';
4+
import * as yamlWriter from '../../third-party-wrappers/write-yaml';
5+
import scaffoldConfig from '../../src/config';
6+
7+
suite('config file generation', () => {
8+
let sandbox;
9+
const projectRoot = any.string();
10+
11+
setup(() => {
12+
sandbox = sinon.createSandbox();
13+
14+
sandbox.stub(yamlWriter, 'default');
15+
16+
yamlWriter.default.resolves();
17+
});
18+
19+
teardown(() => sandbox.restore());
20+
21+
test('that a base config is created for a shell project', async () => {
22+
await scaffoldConfig({projectRoot});
23+
24+
assert.calledWith(
25+
yamlWriter.default,
26+
`${projectRoot}/.travis.yml`,
27+
{
28+
language: 'generic',
29+
notifications: {email: false},
30+
install: 'bpkg getdeps',
31+
script: 'make test'
32+
}
33+
);
34+
});
35+
});

test/unit/scaffolder-test.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
import {assert} from 'chai';
2+
import any from '@travi/any';
3+
import sinon from 'sinon';
4+
import * as configScaffolder from '../../src/config';
25
import {scaffold} from '../../src';
36

47
suite('scaffolder', () => {
5-
test('that the config is scaffolded', () => {
6-
assert.deepEqual(scaffold(), {});
8+
let sandbox;
9+
10+
setup(() => {
11+
sandbox = sinon.createSandbox();
12+
13+
sandbox.stub(configScaffolder, 'default');
14+
});
15+
16+
teardown(() => sandbox.restore());
17+
18+
test('that the config is scaffolded', async () => {
19+
const projectRoot = any.string();
20+
21+
assert.deepEqual(await scaffold({projectRoot}), {});
22+
assert.calledWith(configScaffolder.default, {projectRoot});
723
});
824
});

third-party-wrappers/write-yaml.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {promisify} from 'util';
2+
import yaml from 'write-yaml';
3+
4+
export default promisify(yaml);

0 commit comments

Comments
 (0)