removed mkdirp dependency and replaced with fs.mkdir
This commit is contained in:
@@ -19,7 +19,6 @@ const UrlCache = require('./UrlCache')
|
|||||||
const Path = require('path')
|
const Path = require('path')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const async = require('async')
|
const async = require('async')
|
||||||
const mkdirp = require('mkdirp')
|
|
||||||
const OutputFileFinder = require('./OutputFileFinder')
|
const OutputFileFinder = require('./OutputFileFinder')
|
||||||
const ResourceStateManager = require('./ResourceStateManager')
|
const ResourceStateManager = require('./ResourceStateManager')
|
||||||
const Metrics = require('./Metrics')
|
const Metrics = require('./Metrics')
|
||||||
@@ -302,7 +301,7 @@ module.exports = ResourceWriter = {
|
|||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
return mkdirp(Path.dirname(path), function(error) {
|
return fs.mkdir(Path.dirname(path), { recursive: true }, function(error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
|
|||||||
5
package-lock.json
generated
5
package-lock.json
generated
@@ -3953,11 +3953,6 @@
|
|||||||
"minipass": "^2.2.1"
|
"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": {
|
"mocha": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz",
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
"logger-sharelatex": "^1.9.0",
|
"logger-sharelatex": "^1.9.0",
|
||||||
"lynx": "0.2.0",
|
"lynx": "0.2.0",
|
||||||
"metrics-sharelatex": "^2.5.1",
|
"metrics-sharelatex": "^2.5.1",
|
||||||
"mkdirp": "1.0.3",
|
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"sequelize": "^4.44.4",
|
"sequelize": "^4.44.4",
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ describe('ResourceWriter', function() {
|
|||||||
'./ResourceStateManager': (this.ResourceStateManager = {}),
|
'./ResourceStateManager': (this.ResourceStateManager = {}),
|
||||||
wrench: (this.wrench = {}),
|
wrench: (this.wrench = {}),
|
||||||
'./UrlCache': (this.UrlCache = {}),
|
'./UrlCache': (this.UrlCache = {}),
|
||||||
mkdirp: (this.mkdirp = sinon.stub().callsArg(1)),
|
|
||||||
'./OutputFileFinder': (this.OutputFileFinder = {}),
|
'./OutputFileFinder': (this.OutputFileFinder = {}),
|
||||||
'logger-sharelatex': { log: sinon.stub(), err: sinon.stub() },
|
'logger-sharelatex': { log: sinon.stub(), err: sinon.stub() },
|
||||||
'./Metrics': (this.Metrics = {
|
'./Metrics': (this.Metrics = {
|
||||||
@@ -346,6 +345,7 @@ describe('ResourceWriter', function() {
|
|||||||
describe('_writeResourceToDisk', function() {
|
describe('_writeResourceToDisk', function() {
|
||||||
describe('with a url based resource', function() {
|
describe('with a url based resource', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
this.fs.mkdir = sinon.stub().callsArg(2)
|
||||||
this.resource = {
|
this.resource = {
|
||||||
path: 'main.tex',
|
path: 'main.tex',
|
||||||
url: 'http://www.example.com/main.tex',
|
url: 'http://www.example.com/main.tex',
|
||||||
@@ -363,7 +363,7 @@ describe('ResourceWriter', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should ensure the directory exists', function() {
|
it('should ensure the directory exists', function() {
|
||||||
return this.mkdirp
|
this.fs.mkdir
|
||||||
.calledWith(
|
.calledWith(
|
||||||
path.dirname(path.join(this.basePath, this.resource.path))
|
path.dirname(path.join(this.basePath, this.resource.path))
|
||||||
)
|
)
|
||||||
@@ -397,6 +397,7 @@ describe('ResourceWriter', function() {
|
|||||||
content: 'Hello world'
|
content: 'Hello world'
|
||||||
}
|
}
|
||||||
this.fs.writeFile = sinon.stub().callsArg(2)
|
this.fs.writeFile = sinon.stub().callsArg(2)
|
||||||
|
this.fs.mkdir = sinon.stub().callsArg(2)
|
||||||
return this.ResourceWriter._writeResourceToDisk(
|
return this.ResourceWriter._writeResourceToDisk(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.resource,
|
this.resource,
|
||||||
@@ -406,7 +407,7 @@ describe('ResourceWriter', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should ensure the directory exists', function() {
|
it('should ensure the directory exists', function() {
|
||||||
return this.mkdirp
|
return this.fs.mkdir
|
||||||
.calledWith(
|
.calledWith(
|
||||||
path.dirname(path.join(this.basePath, this.resource.path))
|
path.dirname(path.join(this.basePath, this.resource.path))
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user