From fdbda9e3d6564ec908733c7019305f6a3c363a9f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Sep 2017 15:27:35 +0200 Subject: Add tests for npm run scripts --- server/helpers/core-utils.ts | 11 +++++++++-- server/helpers/custom-validators/misc.ts | 2 ++ server/helpers/custom-validators/pods.ts | 1 + server/helpers/custom-validators/remote/videos.ts | 1 + server/helpers/custom-validators/users.ts | 1 + server/helpers/custom-validators/videos.ts | 1 + 6 files changed, 15 insertions(+), 2 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index f8dd45533..2ec7e6515 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts @@ -25,8 +25,15 @@ function isTestInstance () { } function root () { - // We are in /dist/helpers/utils.js - return join(__dirname, '..', '..', '..') + // We are in /helpers/utils.js + const paths = [ __dirname, '..', '..' ] + + // We are under /dist directory + if (process.mainModule.filename.endsWith('.ts') === false) { + paths.push('..') + } + + return join.apply(null, paths) } function promisify0 (func: (cb: (err: any, result: A) => void) => void): () => Promise { diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index f6bb02c8e..8d215a416 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -1,3 +1,5 @@ +import 'express-validator' + function exists (value: any) { return value !== undefined && value !== null } diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts index f2ca520c0..844bfdf78 100644 --- a/server/helpers/custom-validators/pods.ts +++ b/server/helpers/custom-validators/pods.ts @@ -1,4 +1,5 @@ import * as validator from 'validator' +import 'express-validator' import { isArray, exists } from './misc' import { isTestInstance } from '../core-utils' diff --git a/server/helpers/custom-validators/remote/videos.ts b/server/helpers/custom-validators/remote/videos.ts index 49f76e909..e5c76f3ca 100644 --- a/server/helpers/custom-validators/remote/videos.ts +++ b/server/helpers/custom-validators/remote/videos.ts @@ -1,3 +1,4 @@ +import 'express-validator' import { has, values } from 'lodash' import { diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 00061f9df..805437efa 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -1,5 +1,6 @@ import { values } from 'lodash' import * as validator from 'validator' +import 'express-validator' import { exists } from './misc' import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers' diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 8b3a26644..1d27e47fc 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -1,5 +1,6 @@ import { values } from 'lodash' import * as validator from 'validator' +import 'express-validator' import 'multer' import { -- cgit v1.2.3