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 --- scripts/danger/clean/cleaner.ts | 2 +- scripts/reset-password.ts | 2 +- scripts/update-host.ts | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/danger/clean/cleaner.ts b/scripts/danger/clean/cleaner.ts index d80b8d323..428333528 100644 --- a/scripts/danger/clean/cleaner.ts +++ b/scripts/danger/clean/cleaner.ts @@ -16,7 +16,7 @@ db.init(true) const storageDir = STORAGE[storage] return new Promise((res, rej) => { - rimraf(storageDir, function (err) { + rimraf(storageDir, err => { if (err) return rej(err) console.info('%s deleted.', storageDir) diff --git a/scripts/reset-password.ts b/scripts/reset-password.ts index 5ab7d01e5..f0c06a7bf 100755 --- a/scripts/reset-password.ts +++ b/scripts/reset-password.ts @@ -18,7 +18,7 @@ db.init(true) .then(user => { if (!user) { console.error('User unknown.') - return + process.exit(-1) } const readline = require('readline') diff --git a/scripts/update-host.ts b/scripts/update-host.ts index 5e69e4172..06d84a658 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts @@ -1,8 +1,5 @@ -import { readFileSync, writeFileSync } from 'fs' -import { join } from 'path' -import * as parseTorrent from 'parse-torrent' +import * as Promise from 'bluebird' -import { CONFIG, STATIC_PATHS } from '../server/initializers/constants' import { database as db } from '../server/initializers/database' import { hasFriends } from '../server/lib/friends' @@ -20,11 +17,18 @@ db.init(true) return db.Video.list() }) .then(videos => { + const tasks: Promise[] = [] + videos.forEach(video => { + console.log('Updating video ' + video.uuid) + video.VideoFiles.forEach(file => { - video.createTorrentAndSetInfoHash(file) + tasks.push(video.createTorrentAndSetInfoHash(file)) }) }) + return Promise.all(tasks) + }) + .then(() => { process.exit(0) }) -- cgit v1.2.3