From fab837b94222bf07ada4c971d8b514c02d0eb9f2 Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Tue, 19 May 2020 18:50:03 +0200 Subject: [PATCH] =?UTF-8?q?[ci]=C2=A0add=20format=20check=20on=20tests=20j?= =?UTF-8?q?ob?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 1 + app/modules/crawler/lib/sync/Watcher.ts | 8 +++++++- format.sh | 11 +++++++++++ package.json | 4 ++-- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 format.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e960e8643..be1965504 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -86,6 +86,7 @@ tests: stage: tests script: - npm i + - npm run format:check - npm test # Push coverage to GitLab pages - tar cvzf coverage.tar.gz coverage/ diff --git a/app/modules/crawler/lib/sync/Watcher.ts b/app/modules/crawler/lib/sync/Watcher.ts index c0cfac51f..b7e663dac 100644 --- a/app/modules/crawler/lib/sync/Watcher.ts +++ b/app/modules/crawler/lib/sync/Watcher.ts @@ -265,7 +265,13 @@ export class MultimeterWatcher implements Watcher { if (duration) { const durationSecs = Math.floor(duration / 1000); const durationMillisRemain = duration % 1000; - this.multi.write("\nAll done in " + durationSecs + "." + durationMillisRemain + " seconds.\n"); + this.multi.write( + "\nAll done in " + + durationSecs + + "." + + durationMillisRemain + + " seconds.\n" + ); } else { this.multi.write("\nAll done.\n"); } diff --git a/format.sh b/format.sh new file mode 100755 index 000000000..eb54ab98b --- /dev/null +++ b/format.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "${1}" = "check" ] +then + $HOME/.cargo/bin/cargo fmt -- --check && prettier --list-different "app/**/*.{ts,json}" +elif [ "${1}" = "all" ] +then + $HOME/.cargo/bin/cargo fmt && prettier --write "app/**/*.{ts,json}" +else + echo "first argument must be \"check\" or \"all\"." +fi diff --git a/package.json b/package.json index 22617b162..a6691a256 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "install": "./neon/build.sh", "lint": "lint-staged", "prettier": "prettier --write app/**/*/*.ts", - "format:check": "prettier --list-different \"app/**/*.{ts,json}\"", - "format:all": "prettier --write \"app/**/*.{ts,json}\"" + "format:check": "./format.sh check", + "format:all": "./format.sh all" }, "nyc": { "require": [ -- GitLab