Skip to content

Commit

Permalink
fix(bin): Fix bin execution (#57)
Browse files Browse the repository at this point in the history
- Fix bin name
- Fix bin import
- Fix bin process exit code
- Fix docs

Closes #48.
  • Loading branch information
dominique-mueller committed Mar 8, 2021
1 parent 0214a83 commit 13a0d30
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 84 deletions.
52 changes: 34 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

**Analyzes your project for focused or ignored tests.**

[![npm version](https://img.shields.io/npm/v/no-skipped-tests.svg?maxAge=3600&style=flat)](https://www.npmjs.com/package/no-skipped-tests)
[![dependency status](https://img.shields.io/david/dominique-mueller/no-skipped-tests.svg?maxAge=3600&style=flat)](https://david-dm.org/dominique-mueller/no-skipped-tests)
[![travis ci build status](https://img.shields.io/travis/dominique-mueller/no-skipped-tests/master.svg?maxAge=3600&style=flat)](https://travis-ci.org/dominique-mueller/no-skipped-tests)
[![Codecov](https://img.shields.io/codecov/c/github/dominique-mueller/no-skipped-tests.svg?maxAge=3600&style=flat)](https://codecov.io/gh/dominique-mueller/no-skipped-tests)
[![Known Vulnerabilities](https://snyk.io/test/github/dominique-mueller/no-skipped-tests/badge.svg)](https://snyk.io/test/github/dominique-mueller/no-skipped-tests)
[![license](https://img.shields.io/npm/l/no-skipped-tests.svg?maxAge=3600&style=flat)](https://github.com/dominique-mueller/no-skipped-tests/LICENSE)
[![npm version](https://img.shields.io/npm/v/no-skipped-tests?style=flat-square)](https://www.npmjs.com/package/no-skipped-tests)
[![travis ci build status](https://img.shields.io/travis/dominique-mueller/no-skipped-tests/master?style=flat-square)](https://travis-ci.org/dominique-mueller/no-skipped-tests)
[![Codecov](https://img.shields.io/codecov/c/github/dominique-mueller/no-skipped-tests/master?style=flat-square)](https://codecov.io/gh/dominique-mueller/no-skipped-tests)
[![Known Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/dominique-mueller/no-skipped-tests?style=flat-square)](https://snyk.io/test/github/dominique-mueller/no-skipped-tests)
[![license](https://img.shields.io/github/license/dominique-mueller/no-skipped-tests?flat-square)](https://github.com/dominique-mueller/no-skipped-tests/LICENSE)

</div>

Expand All @@ -32,42 +31,59 @@ The **no-skipped-tests** is here to help; it is a NodeJS-based command line tool
You can get **no-skipped-tests** via **npm** by either adding it as a new devDependency to your `package.json` file and running
`npm install`, or running the following command:

``` bash
```bash
npm install no-skipped-tests --save-dev
```

### Requirements
**Requirements**

- **no-skipped-tests** requires at least **NodeJS 7.6** (or higher). *Earlier 7.x versions of NodeJS (7.0 to 7.5) might also work when
executing **no-skipped-tests** using the `--harmony-async-await` flag.*
- **no-skipped-tests** requires at least **NodeJS 7.6** (or higher). _Earlier 7.x versions of NodeJS (7.0 to 7.5) might also work when
executing **no-skipped-tests** using the `--harmony-async-await` flag._

<br><br>

## How to use

Using **no-skipped-tests** is very straightforward: Simply call it within one of the scripts of your `package.json` file. For instance, you
can let it get executed automatically before every test by using the `pretest` script:
The most common way to use **no-skipped-tests** is adding it to the scripts area within your `package.json` file. For example:

``` json
```json
{
"scripts": {
"no-skipped-tests": "no-skipped-tests"
}
}
```

Then, execute it by running:

```bash
npm run no-skipped-tests
```

You can also let npm run **no-skipped-tests** automatically before every test execution by using the `pretest` script:

```json
{
"scripts": {
"pretest": "no-skipped-tests"
}
}
```

Alternatively, you can also run it manually:
Alternatively, if you want to run **no-skipped-tests** from scratch, you can use an `npx` command:

``` bash
npm run pretest
```bash
npx no-skipped-tests
```

<br>

### Configuration

By default, **no-skipped-tests** will analyue all test files within your source folder: `src/**/*.spec.@(ts|js)`. However, your project
By default, **no-skipped-tests** will analyze all test files within your source folder: `src/**/*.spec.@(ts|js)`. However, your project
might have a different naming convention or directory structure. Thus, you might provide a custom file pattern instead. For instance:

``` json
```json
{
"scripts": {
"pretest": "no-skipped-tests src/app/**/*.test.ts"
Expand Down
17 changes: 9 additions & 8 deletions bin/no-skipped-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

'use strict';

const chalk = require( 'chalk' );

const analyzeFilesForSkippedTests = require( './../dist/index' ).analyzeFilesForSkippedTests;
const analyzeFilesForSkippedTests = require( './../index' ).analyzeFilesForSkippedTests;

// Collect command line parameters (only source pattern for now)
const parameters = process.argv.slice( 2 );
Expand All @@ -18,11 +16,14 @@ console.log( '' );
analyzeFilesForSkippedTests( options )
.then( ( results ) => {
console.log( '' );
if ( results.length === 0 ) {
process.exit( 0 );
} else {
process.exit( 1 );
}
const hasErrors = results
.map((result) => {
return result.errors.length;
})
.reduce((a, b) => {
return a + b;
})
process.exit( hasErrors ? 1 : 0 );
} )
.catch( ( error ) => {
console.log( '' );
Expand Down
105 changes: 47 additions & 58 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,49 @@
{
"name": "no-skipped-tests",
"description": "Analyzes your project for focused or ignored tests.",
"version": "1.0.0",
"author": {
"name": "Dominique Müller",
"email": "dominique.m.mueller@gmail.com",
"url": "https://www.devdom.io/"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/dominique-mueller/no-skipped-tests.git"
},
"homepage": "https://github.com/dominique-mueller/no-skipped-tests",
"bugs": {
"url": "https://github.com/dominique-mueller/no-skipped-tests/issues"
},
"keywords": [
"test",
"skip",
"fdescribe",
"xdescribe",
"fit",
"xit",
"jasmine",
"karma",
"angular",
"typescript",
"javascript"
],
"main": "index.js",
"types": "index.d.ts",
"bin": {
"automatic-release": "bin/no-skipped-tests.js"
},
"scripts": {
"build": "tsc -p tsconfig.json && copyfiles \"bin/**\" dist",
"clean": "rimraf -r dist/*",
"release": "automatic-release && copyfiles \"docs/**\" package.json CHANGELOG.md LICENSE README.md dist",
"test:coverage": "codecov -f coverage/coverage-final.json",
"test": "jest --config jest.config.json --runInBand --no-cache"
},
"dependencies": {
"chalk": "2.4.x",
"glob": "7.1.x",
"ora": "3.0.x",
"typescript": "3.0.x"
},
"devDependencies": {
"@types/jest": "23.1.x",
"@types/node": "8.10.x",
"automatic-release": "1.1.x",
"codecov": "3.0.x",
"copyfiles": "2.1.x",
"jest": "23.5.x",
"rimraf": "2.6.x",
"ts-jest": "22.4.x"
}
"name": "no-skipped-tests",
"description": "Analyzes your project for focused or ignored tests",
"version": "1.0.0",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/dominique-mueller/no-skipped-tests.git"
},
"keywords": [
"test",
"skip",
"fdescribe",
"xdescribe",
"fit",
"xit",
"jasmine",
"karma",
"angular",
"typescript",
"javascript"
],
"main": "index.js",
"types": "index.d.ts",
"bin": {
"no-skipped-tests": "bin/no-skipped-tests.js"
},
"scripts": {
"build": "rimraf -r dist && tsc -p tsconfig.json && copyfiles \"bin/**\" \"docs/**\" package.json CHANGELOG.md LICENSE README.MD dist",
"test:coverage": "codecov -f coverage/coverage-final.json",
"test": "jest --config jest.config.json --runInBand --no-cache"
},
"dependencies": {
"chalk": "2.4.x",
"glob": "7.1.x",
"ora": "3.0.x",
"typescript": "3.0.x"
},
"devDependencies": {
"@types/jest": "23.1.x",
"@types/node": "8.10.x",
"automatic-release": "1.1.x",
"codecov": "3.0.x",
"copyfiles": "2.1.x",
"jest": "23.5.x",
"rimraf": "2.6.x",
"ts-jest": "22.4.x"
}
}

0 comments on commit 13a0d30

Please sign in to comment.