Skip to content

Commit 2c27b8b

Browse files
authored
Merge pull request #11 from form8ion/alpha
2 parents 2a94b15 + 0662547 commit 2c27b8b

File tree

8 files changed

+62
-12
lines changed

8 files changed

+62
-12
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# octoherd-script
22

3-
form8ion plugin to manage script projects for octoherd
3+
[form8ion](https://github.com/form8ion) plugin to manage script projects for
4+
[octoherd](https://github.com/octoherd)
45

56
<!--status-badges start -->
67

src/canary-test.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/scaffolder-test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {promises as fs} from 'fs';
2+
3+
import any from '@travi/any';
4+
import sinon from 'sinon';
5+
import {assert} from 'chai';
6+
7+
import scaffold from './scaffolder';
8+
9+
suite('scaffold script', () => {
10+
let sandbox;
11+
12+
setup(() => {
13+
sandbox = sinon.createSandbox();
14+
15+
sandbox.stub(fs, 'writeFile');
16+
});
17+
18+
teardown(() => sandbox.restore());
19+
20+
test('that the script is scaffolded', async () => {
21+
const projectRoot = any.string();
22+
23+
const {tags} = await scaffold({projectRoot});
24+
25+
assert.calledWith(fs.writeFile, `${projectRoot}/index.js`, 'export async function script(octokit, repository) {}');
26+
assert.deepEqual(tags, ['octoherd-script']);
27+
});
28+
});

src/scaffolder.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
export default function () {
2-
return undefined;
1+
import {promises as fs} from 'fs';
2+
3+
export default async function ({projectRoot}) {
4+
await fs.writeFile(`${projectRoot}/index.js`, 'export async function script(octokit, repository) {}');
5+
6+
return {tags: ['octoherd-script']};
37
}

test/integration/features/scaffolder.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ Feature: Scaffolder
22

33
Scenario: Scaffold
44
When the project is scaffolded
5+
Then the script file is bootstrapped
6+
And project metadata is generated

test/integration/features/step_definitions/common-steps.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import {dirname, resolve} from 'node:path';
22
import {fileURLToPath} from 'node:url';
33

4-
import {After, When} from '@cucumber/cucumber';
4+
import {After, Before, When} from '@cucumber/cucumber';
55
import stubbedFs from 'mock-fs';
66

77
const __dirname = dirname(fileURLToPath(import.meta.url));
88
const stubbedNodeModules = stubbedFs.load(resolve(__dirname, '..', '..', '..', '..', 'node_modules'));
99

10+
Before(function () {
11+
this.projectRoot = process.cwd();
12+
})
13+
1014
After(function () {
1115
stubbedFs.restore();
1216
});
@@ -19,5 +23,5 @@ When('the project is scaffolded', async function () {
1923
node_modules: stubbedNodeModules
2024
});
2125

22-
await scaffold({projectRoot: process.cwd()});
26+
this.result = await scaffold({projectRoot: this.projectRoot});
2327
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {Then} from '@cucumber/cucumber';
2+
import {assert} from 'chai';
3+
4+
Then('project metadata is generated', async function () {
5+
const {tags} = this.result;
6+
7+
assert.deepEqual(tags, ['octoherd-script']);
8+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {promises as fs} from 'fs';
2+
3+
import {Then} from '@cucumber/cucumber';
4+
import {assert} from 'chai';
5+
6+
Then('the script file is bootstrapped', async function () {
7+
const scriptContent = await fs.readFile(`${this.projectRoot}/index.js`, 'utf-8');
8+
9+
assert.equal(scriptContent, `export async function script(octokit, repository) {}`);
10+
});

0 commit comments

Comments
 (0)