1
0
mirror of https://github.com/S2-/gitlit synced 2025-08-04 13:10:09 +02:00

update dependencies

This commit is contained in:
s2
2018-10-10 15:11:12 +02:00
parent da4083f574
commit 5c55c54b71
90877 changed files with 339776 additions and 33677 deletions

View File

@@ -1,21 +1,26 @@
var path = require('path')
var fs = require('graceful-fs')
var mkdir = require('../mkdirs')
'use strict'
const u = require('universalify').fromCallback
const path = require('path')
const fs = require('graceful-fs')
const mkdir = require('../mkdirs')
const pathExists = require('../path-exists').pathExists
function createFile (file, callback) {
function makeFile () {
fs.writeFile(file, '', function (err) {
fs.writeFile(file, '', err => {
if (err) return callback(err)
callback()
})
}
fs.exists(file, function (fileExists) {
if (fileExists) return callback()
var dir = path.dirname(file)
fs.exists(dir, function (dirExists) {
fs.stat(file, (err, stats) => { // eslint-disable-line handle-callback-err
if (!err && stats.isFile()) return callback()
const dir = path.dirname(file)
pathExists(dir, (err, dirExists) => {
if (err) return callback(err)
if (dirExists) return makeFile()
mkdir.mkdirs(dir, function (err) {
mkdir.mkdirs(dir, err => {
if (err) return callback(err)
makeFile()
})
@@ -24,9 +29,13 @@ function createFile (file, callback) {
}
function createFileSync (file) {
if (fs.existsSync(file)) return
let stats
try {
stats = fs.statSync(file)
} catch (e) {}
if (stats && stats.isFile()) return
var dir = path.dirname(file)
const dir = path.dirname(file)
if (!fs.existsSync(dir)) {
mkdir.mkdirsSync(dir)
}
@@ -35,9 +44,6 @@ function createFileSync (file) {
}
module.exports = {
createFile: createFile,
createFileSync: createFileSync,
// alias
ensureFile: createFile,
ensureFileSync: createFileSync
createFile: u(createFile),
createFileSync
}

View File

@@ -1,6 +1,8 @@
var file = require('./file')
var link = require('./link')
var symlink = require('./symlink')
'use strict'
const file = require('./file')
const link = require('./link')
const symlink = require('./symlink')
module.exports = {
// file

View File

@@ -1,27 +1,33 @@
var path = require('path')
var fs = require('graceful-fs')
var mkdir = require('../mkdirs')
'use strict'
const u = require('universalify').fromCallback
const path = require('path')
const fs = require('graceful-fs')
const mkdir = require('../mkdirs')
const pathExists = require('../path-exists').pathExists
function createLink (srcpath, dstpath, callback) {
function makeLink (srcpath, dstpath) {
fs.link(srcpath, dstpath, function (err) {
fs.link(srcpath, dstpath, err => {
if (err) return callback(err)
callback(null)
})
}
fs.exists(dstpath, function (destinationExists) {
pathExists(dstpath, (err, destinationExists) => {
if (err) return callback(err)
if (destinationExists) return callback(null)
fs.lstat(srcpath, function (err, stat) {
fs.lstat(srcpath, (err, stat) => {
if (err) {
err.message = err.message.replace('lstat', 'ensureLink')
return callback(err)
}
var dir = path.dirname(dstpath)
fs.exists(dir, function (dirExists) {
const dir = path.dirname(dstpath)
pathExists(dir, (err, dirExists) => {
if (err) return callback(err)
if (dirExists) return makeLink(srcpath, dstpath)
mkdir.mkdirs(dir, function (err) {
mkdir.mkdirs(dir, err => {
if (err) return callback(err)
makeLink(srcpath, dstpath)
})
@@ -31,7 +37,7 @@ function createLink (srcpath, dstpath, callback) {
}
function createLinkSync (srcpath, dstpath, callback) {
var destinationExists = fs.existsSync(dstpath)
const destinationExists = fs.existsSync(dstpath)
if (destinationExists) return undefined
try {
@@ -41,8 +47,8 @@ function createLinkSync (srcpath, dstpath, callback) {
throw err
}
var dir = path.dirname(dstpath)
var dirExists = fs.existsSync(dir)
const dir = path.dirname(dstpath)
const dirExists = fs.existsSync(dir)
if (dirExists) return fs.linkSync(srcpath, dstpath)
mkdir.mkdirsSync(dir)
@@ -50,9 +56,6 @@ function createLinkSync (srcpath, dstpath, callback) {
}
module.exports = {
createLink: createLink,
createLinkSync: createLinkSync,
// alias
ensureLink: createLink,
ensureLinkSync: createLinkSync
createLink: u(createLink),
createLinkSync
}

View File

@@ -1,7 +1,8 @@
var path = require('path')
// path.isAbsolute shim for Node.js 0.10 support
path.isAbsolute = (path.isAbsolute) ? path.isAbsolute : require('path-is-absolute')
var fs = require('graceful-fs')
'use strict'
const path = require('path')
const fs = require('graceful-fs')
const pathExists = require('../path-exists').pathExists
/**
* Function that returns two types of paths, one relative to symlink, and one
@@ -27,7 +28,7 @@ var fs = require('graceful-fs')
function symlinkPaths (srcpath, dstpath, callback) {
if (path.isAbsolute(srcpath)) {
return fs.lstat(srcpath, function (err, stat) {
return fs.lstat(srcpath, (err, stat) => {
if (err) {
err.message = err.message.replace('lstat', 'ensureSymlink')
return callback(err)
@@ -38,16 +39,17 @@ function symlinkPaths (srcpath, dstpath, callback) {
})
})
} else {
var dstdir = path.dirname(dstpath)
var relativeToDst = path.join(dstdir, srcpath)
return fs.exists(relativeToDst, function (exists) {
const dstdir = path.dirname(dstpath)
const relativeToDst = path.join(dstdir, srcpath)
return pathExists(relativeToDst, (err, exists) => {
if (err) return callback(err)
if (exists) {
return callback(null, {
'toCwd': relativeToDst,
'toDst': srcpath
})
} else {
return fs.lstat(srcpath, function (err, stat) {
return fs.lstat(srcpath, (err, stat) => {
if (err) {
err.message = err.message.replace('lstat', 'ensureSymlink')
return callback(err)
@@ -63,7 +65,7 @@ function symlinkPaths (srcpath, dstpath, callback) {
}
function symlinkPathsSync (srcpath, dstpath) {
var exists
let exists
if (path.isAbsolute(srcpath)) {
exists = fs.existsSync(srcpath)
if (!exists) throw new Error('absolute srcpath does not exist')
@@ -72,8 +74,8 @@ function symlinkPathsSync (srcpath, dstpath) {
'toDst': srcpath
}
} else {
var dstdir = path.dirname(dstpath)
var relativeToDst = path.join(dstdir, srcpath)
const dstdir = path.dirname(dstpath)
const relativeToDst = path.join(dstdir, srcpath)
exists = fs.existsSync(relativeToDst)
if (exists) {
return {
@@ -92,6 +94,6 @@ function symlinkPathsSync (srcpath, dstpath) {
}
module.exports = {
'symlinkPaths': symlinkPaths,
'symlinkPathsSync': symlinkPathsSync
symlinkPaths,
symlinkPathsSync
}

View File

@@ -1,10 +1,12 @@
var fs = require('graceful-fs')
'use strict'
const fs = require('graceful-fs')
function symlinkType (srcpath, type, callback) {
callback = (typeof type === 'function') ? type : callback
type = (typeof type === 'function') ? false : type
if (type) return callback(null, type)
fs.lstat(srcpath, function (err, stats) {
fs.lstat(srcpath, (err, stats) => {
if (err) return callback(null, 'file')
type = (stats && stats.isDirectory()) ? 'dir' : 'file'
callback(null, type)
@@ -12,9 +14,11 @@ function symlinkType (srcpath, type, callback) {
}
function symlinkTypeSync (srcpath, type) {
let stats
if (type) return type
try {
var stats = fs.lstatSync(srcpath)
stats = fs.lstatSync(srcpath)
} catch (e) {
return 'file'
}
@@ -22,6 +26,6 @@ function symlinkTypeSync (srcpath, type) {
}
module.exports = {
symlinkType: symlinkType,
symlinkTypeSync: symlinkTypeSync
symlinkType,
symlinkTypeSync
}

View File

@@ -1,32 +1,39 @@
var path = require('path')
var fs = require('graceful-fs')
var _mkdirs = require('../mkdirs')
var mkdirs = _mkdirs.mkdirs
var mkdirsSync = _mkdirs.mkdirsSync
'use strict'
var _symlinkPaths = require('./symlink-paths')
var symlinkPaths = _symlinkPaths.symlinkPaths
var symlinkPathsSync = _symlinkPaths.symlinkPathsSync
const u = require('universalify').fromCallback
const path = require('path')
const fs = require('graceful-fs')
const _mkdirs = require('../mkdirs')
const mkdirs = _mkdirs.mkdirs
const mkdirsSync = _mkdirs.mkdirsSync
var _symlinkType = require('./symlink-type')
var symlinkType = _symlinkType.symlinkType
var symlinkTypeSync = _symlinkType.symlinkTypeSync
const _symlinkPaths = require('./symlink-paths')
const symlinkPaths = _symlinkPaths.symlinkPaths
const symlinkPathsSync = _symlinkPaths.symlinkPathsSync
const _symlinkType = require('./symlink-type')
const symlinkType = _symlinkType.symlinkType
const symlinkTypeSync = _symlinkType.symlinkTypeSync
const pathExists = require('../path-exists').pathExists
function createSymlink (srcpath, dstpath, type, callback) {
callback = (typeof type === 'function') ? type : callback
type = (typeof type === 'function') ? false : type
fs.exists(dstpath, function (destinationExists) {
pathExists(dstpath, (err, destinationExists) => {
if (err) return callback(err)
if (destinationExists) return callback(null)
symlinkPaths(srcpath, dstpath, function (err, relative) {
symlinkPaths(srcpath, dstpath, (err, relative) => {
if (err) return callback(err)
srcpath = relative.toDst
symlinkType(relative.toCwd, type, function (err, type) {
symlinkType(relative.toCwd, type, (err, type) => {
if (err) return callback(err)
var dir = path.dirname(dstpath)
fs.exists(dir, function (dirExists) {
const dir = path.dirname(dstpath)
pathExists(dir, (err, dirExists) => {
if (err) return callback(err)
if (dirExists) return fs.symlink(srcpath, dstpath, type, callback)
mkdirs(dir, function (err) {
mkdirs(dir, err => {
if (err) return callback(err)
fs.symlink(srcpath, dstpath, type, callback)
})
@@ -40,23 +47,20 @@ function createSymlinkSync (srcpath, dstpath, type, callback) {
callback = (typeof type === 'function') ? type : callback
type = (typeof type === 'function') ? false : type
var destinationExists = fs.existsSync(dstpath)
const destinationExists = fs.existsSync(dstpath)
if (destinationExists) return undefined
var relative = symlinkPathsSync(srcpath, dstpath)
const relative = symlinkPathsSync(srcpath, dstpath)
srcpath = relative.toDst
type = symlinkTypeSync(relative.toCwd, type)
var dir = path.dirname(dstpath)
var exists = fs.existsSync(dir)
const dir = path.dirname(dstpath)
const exists = fs.existsSync(dir)
if (exists) return fs.symlinkSync(srcpath, dstpath, type)
mkdirsSync(dir)
return fs.symlinkSync(srcpath, dstpath, type)
}
module.exports = {
createSymlink: createSymlink,
createSymlinkSync: createSymlinkSync,
// alias
ensureSymlink: createSymlink,
ensureSymlinkSync: createSymlinkSync
createSymlink: u(createSymlink),
createSymlinkSync
}