@scalvert/bin-tester 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -71,6 +71,10 @@ var BinTesterProject = class extends import_fixturify_project.Project {
71
71
  this._dirChanged = true;
72
72
  process.chdir(this.baseDir);
73
73
  }
74
+ writeJSON(dirJSON) {
75
+ this.files = __spreadValues(__spreadValues({}, this.files), dirJSON);
76
+ return super.write();
77
+ }
74
78
  dispose() {
75
79
  if (this._dirChanged) {
76
80
  process.chdir(ROOT);
@@ -91,11 +95,12 @@ var DEFAULT_RUN_OPTIONS = {
91
95
  function createBinTester(options) {
92
96
  let project;
93
97
  const mergedOptions = __spreadValues(__spreadValues({}, DEFAULT_BIN_TESTER_OPTIONS), options);
94
- function runBin(runOptions = DEFAULT_RUN_OPTIONS) {
95
- return (0, import_execa2.default)(process.execPath, [mergedOptions.binPath, ...mergedOptions.staticArgs, ...runOptions.args], __spreadValues({
98
+ function runBin(runOptions = {}) {
99
+ const mergedRunOptions = __spreadValues(__spreadValues({}, DEFAULT_RUN_OPTIONS), runOptions);
100
+ return (0, import_execa2.default)(process.execPath, [mergedOptions.binPath, ...mergedOptions.staticArgs, ...mergedRunOptions.args], __spreadValues({
96
101
  reject: false,
97
102
  cwd: project.baseDir
98
- }, runOptions.execaOptions));
103
+ }, mergedRunOptions.execaOptions));
99
104
  }
100
105
  async function setupProject() {
101
106
  project = new mergedOptions.projectConstructor();
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import execa from 'execa';
2
+ import { Constructor } from 'type-fest';
3
+ import fixturify from 'fixturify';
2
4
  import { Project } from 'fixturify-project';
3
5
 
4
6
  declare class BinTesterProject extends Project {
@@ -6,10 +8,11 @@ declare class BinTesterProject extends Project {
6
8
  constructor(name?: string, version?: string, cb?: (project: Project) => void);
7
9
  gitInit(): execa.ExecaChildProcess<string>;
8
10
  chdir(): void;
11
+ writeJSON(dirJSON: fixturify.DirJSON): Promise<void>;
9
12
  dispose(): void;
10
13
  }
11
14
 
12
- interface BinTesterOptions {
15
+ interface BinTesterOptions<TProject> {
13
16
  /**
14
17
  * The absolute path to the bin to invoke
15
18
  */
@@ -21,13 +24,13 @@ interface BinTesterOptions {
21
24
  /**
22
25
  * An optional class to use to create the project
23
26
  */
24
- projectConstructor?: any;
27
+ projectConstructor?: Constructor<TProject>;
25
28
  }
26
29
  interface RunOptions {
27
30
  /**
28
31
  * Arguments to provide to the bin script.
29
32
  */
30
- args: string[];
33
+ args?: string[];
31
34
  /**
32
35
  * Options to provide to execa. @see https://github.com/sindresorhus/execa#options
33
36
  */
@@ -45,6 +48,6 @@ interface CreateBinTesterResult<TProject extends BinTesterProject> {
45
48
  * @param options - An object of bin tester options
46
49
  * @returns - A project instance.
47
50
  */
48
- declare function createBinTester<TProject extends BinTesterProject>(options: BinTesterOptions): CreateBinTesterResult<TProject>;
51
+ declare function createBinTester<TProject extends BinTesterProject>(options: BinTesterOptions<TProject>): CreateBinTesterResult<TProject>;
49
52
 
50
53
  export { BinTesterProject, createBinTester };
package/dist/index.js CHANGED
@@ -39,6 +39,10 @@ var BinTesterProject = class extends Project {
39
39
  this._dirChanged = true;
40
40
  process.chdir(this.baseDir);
41
41
  }
42
+ writeJSON(dirJSON) {
43
+ this.files = __spreadValues(__spreadValues({}, this.files), dirJSON);
44
+ return super.write();
45
+ }
42
46
  dispose() {
43
47
  if (this._dirChanged) {
44
48
  process.chdir(ROOT);
@@ -59,11 +63,12 @@ var DEFAULT_RUN_OPTIONS = {
59
63
  function createBinTester(options) {
60
64
  let project;
61
65
  const mergedOptions = __spreadValues(__spreadValues({}, DEFAULT_BIN_TESTER_OPTIONS), options);
62
- function runBin(runOptions = DEFAULT_RUN_OPTIONS) {
63
- return execa2(process.execPath, [mergedOptions.binPath, ...mergedOptions.staticArgs, ...runOptions.args], __spreadValues({
66
+ function runBin(runOptions = {}) {
67
+ const mergedRunOptions = __spreadValues(__spreadValues({}, DEFAULT_RUN_OPTIONS), runOptions);
68
+ return execa2(process.execPath, [mergedOptions.binPath, ...mergedOptions.staticArgs, ...mergedRunOptions.args], __spreadValues({
64
69
  reject: false,
65
70
  cwd: project.baseDir
66
- }, runOptions.execaOptions));
71
+ }, mergedRunOptions.execaOptions));
67
72
  }
68
73
  async function setupProject() {
69
74
  project = new mergedOptions.projectConstructor();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalvert/bin-tester",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A test harness to invoke a CLI in a tmp directory",
5
5
  "keywords": [
6
6
  "cli",
@@ -52,6 +52,7 @@
52
52
  "eslint-plugin-prettier": "^4.0.0",
53
53
  "eslint-plugin-tsdoc": "^0.2.14",
54
54
  "eslint-plugin-unicorn": "^41.0.0",
55
+ "fixturify": "^2.1.1",
55
56
  "prettier": "^2.5.1",
56
57
  "release-it": "^14.2.1",
57
58
  "release-it-lerna-changelog": "^3.1.0",