From 4169f7fc73da71f25b2c06cecce39421622a4bf2 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 18 Dec 2020 15:16:46 +0000 Subject: [PATCH] use once for callback --- services/clsi/app/js/OutputFileFinder.js | 4 +++- services/clsi/test/unit/js/OutputFileFinderTests.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/services/clsi/app/js/OutputFileFinder.js b/services/clsi/app/js/OutputFileFinder.js index 1f62a7568d..38fdc7945e 100644 --- a/services/clsi/app/js/OutputFileFinder.js +++ b/services/clsi/app/js/OutputFileFinder.js @@ -2,6 +2,7 @@ let OutputFileFinder const async = require('async') const fs = require('fs') const Path = require('path') +const _ = require('lodash') const { spawn } = require('child_process') const logger = require('logger-sharelatex') @@ -32,7 +33,8 @@ module.exports = OutputFileFinder = { }) }, - _getAllFiles(directory, _callback) { + _getAllFiles(directory, callback) { + callback = _.once(callback) // don't include clsi-specific files/directories in the output list const EXCLUDE_DIRS = [ '-name', diff --git a/services/clsi/test/unit/js/OutputFileFinderTests.js b/services/clsi/test/unit/js/OutputFileFinderTests.js index 4afa25e83e..8744c6e779 100644 --- a/services/clsi/test/unit/js/OutputFileFinderTests.js +++ b/services/clsi/test/unit/js/OutputFileFinderTests.js @@ -28,6 +28,9 @@ describe('OutputFileFinder', function () { fs: (this.fs = {}), child_process: { spawn: (this.spawn = sinon.stub()) }, 'logger-sharelatex': { log: sinon.stub(), warn: sinon.stub() } + }, + globals: { + Math // used by lodash } }) this.directory = '/test/dir'