Просмотр исходного кода

removed mkdirp dependency and replaced with fs.mkdir

mserranom 6 лет назад
Родитель
Сommit
cf6c8ab496

+ 1 - 2
services/clsi/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)
         }

+ 0 - 5
services/clsi/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",

+ 0 - 1
services/clsi/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",

+ 4 - 3
services/clsi/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))
           )