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

Commit

Permalink
feat(config): difined the travis config file
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Mar 23, 2019
1 parent c54b37d commit 33da70a
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 11 deletions.
59 changes: 51 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@
"rollup-plugin-auto-external": "^2.0.0",
"sinon": "^7.3.0",
"travis-lint": "^1.0.0"
},
"dependencies": {
"write-yaml": "^1.0.0"
}
}
8 changes: 8 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import writeYaml from '../third-party-wrappers/write-yaml';

export default function ({projectRoot}) {
return writeYaml(
`${projectRoot}/.travis.yml`,
{language: 'generic', notifications: {email: false}, install: 'bpkg getdeps', script: 'make test'}
);
}
6 changes: 5 additions & 1 deletion src/scaffolder.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export default function () {
import scaffoldConfig from './config';

export default async function ({projectRoot}) {
await scaffoldConfig({projectRoot});

return {};
}
35 changes: 35 additions & 0 deletions test/unit/config-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import sinon from 'sinon';
import {assert} from 'chai';
import any from '@travi/any';
import * as yamlWriter from '../../third-party-wrappers/write-yaml';
import scaffoldConfig from '../../src/config';

suite('config file generation', () => {
let sandbox;
const projectRoot = any.string();

setup(() => {
sandbox = sinon.createSandbox();

sandbox.stub(yamlWriter, 'default');

yamlWriter.default.resolves();
});

teardown(() => sandbox.restore());

test('that a base config is created for a shell project', async () => {
await scaffoldConfig({projectRoot});

assert.calledWith(
yamlWriter.default,
`${projectRoot}/.travis.yml`,
{
language: 'generic',
notifications: {email: false},
install: 'bpkg getdeps',
script: 'make test'
}
);
});
});
20 changes: 18 additions & 2 deletions test/unit/scaffolder-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import {assert} from 'chai';
import any from '@travi/any';
import sinon from 'sinon';
import * as configScaffolder from '../../src/config';
import {scaffold} from '../../src';

suite('scaffolder', () => {
test('that the config is scaffolded', () => {
assert.deepEqual(scaffold(), {});
let sandbox;

setup(() => {
sandbox = sinon.createSandbox();

sandbox.stub(configScaffolder, 'default');
});

teardown(() => sandbox.restore());

test('that the config is scaffolded', async () => {
const projectRoot = any.string();

assert.deepEqual(await scaffold({projectRoot}), {});
assert.calledWith(configScaffolder.default, {projectRoot});
});
});
4 changes: 4 additions & 0 deletions third-party-wrappers/write-yaml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {promisify} from 'util';
import yaml from 'write-yaml';

export default promisify(yaml);

0 comments on commit 33da70a

Please sign in to comment.