diff --git a/app/js/ResourceWriter.js b/app/js/ResourceWriter.js index ba9706b..5a234e0 100644 --- a/app/js/ResourceWriter.js +++ b/app/js/ResourceWriter.js @@ -19,7 +19,6 @@ const UrlCache = require('./UrlCache') const Path = require('path') const fs = require('fs') const async = require('async') -const mkdirp = require('mkdirp') const OutputFileFinder = require('./OutputFileFinder') const ResourceStateManager = require('./ResourceStateManager') const Metrics = require('./Metrics') @@ -302,7 +301,7 @@ module.exports = ResourceWriter = { if (error != null) { return callback(error) } - return mkdirp(Path.dirname(path), function(error) { + return fs.mkdir(Path.dirname(path), { recursive: true }, function(error) { if (error != null) { return callback(error) } diff --git a/package-lock.json b/package-lock.json index 42d16ee..c7b9e4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3953,11 +3953,6 @@ "minipass": "^2.2.1" } }, - "mkdirp": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.3.tgz", - "integrity": "sha512-6uCP4Qc0sWsgMLy1EOqqS/3rjDHOEnsStVr/4vtAIK2Y5i2kA7lFFejYrpIyiN9w0pYf4ckeCYT9f1r1P9KX5g==" - }, "mocha": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz", diff --git a/package.json b/package.json index 659726b..7317cae 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "logger-sharelatex": "^1.9.0", "lynx": "0.2.0", "metrics-sharelatex": "^2.5.1", - "mkdirp": "1.0.3", "mysql": "^2.18.1", "request": "^2.88.2", "sequelize": "^4.44.4", diff --git a/test/unit/js/ResourceWriterTests.js b/test/unit/js/ResourceWriterTests.js index 189908d..b542f25 100644 --- a/test/unit/js/ResourceWriterTests.js +++ b/test/unit/js/ResourceWriterTests.js @@ -31,7 +31,6 @@ describe('ResourceWriter', function() { './ResourceStateManager': (this.ResourceStateManager = {}), wrench: (this.wrench = {}), './UrlCache': (this.UrlCache = {}), - mkdirp: (this.mkdirp = sinon.stub().callsArg(1)), './OutputFileFinder': (this.OutputFileFinder = {}), 'logger-sharelatex': { log: sinon.stub(), err: sinon.stub() }, './Metrics': (this.Metrics = { @@ -346,6 +345,7 @@ describe('ResourceWriter', function() { describe('_writeResourceToDisk', function() { describe('with a url based resource', function() { beforeEach(function() { + this.fs.mkdir = sinon.stub().callsArg(2) this.resource = { path: 'main.tex', url: 'http://www.example.com/main.tex', @@ -363,7 +363,7 @@ describe('ResourceWriter', function() { }) it('should ensure the directory exists', function() { - return this.mkdirp + this.fs.mkdir .calledWith( path.dirname(path.join(this.basePath, this.resource.path)) ) @@ -397,6 +397,7 @@ describe('ResourceWriter', function() { content: 'Hello world' } this.fs.writeFile = sinon.stub().callsArg(2) + this.fs.mkdir = sinon.stub().callsArg(2) return this.ResourceWriter._writeResourceToDisk( this.project_id, this.resource, @@ -406,7 +407,7 @@ describe('ResourceWriter', function() { }) it('should ensure the directory exists', function() { - return this.mkdirp + return this.fs.mkdir .calledWith( path.dirname(path.join(this.basePath, this.resource.path)) )