Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const u = require('universalify').fromCallback
const jsonFile = require('./jsonfile')
jsonFile.outputJson = u(require('./output-json'))
jsonFile.outputJsonSync = require('./output-json-sync')
// aliases
jsonFile.outputJSON = jsonFile.outputJson
jsonFile.outputJSONSync = jsonFile.outputJsonSync
jsonFile.writeJSON = jsonFile.writeJson
jsonFile.writeJSONSync = jsonFile.writeJsonSync
jsonFile.readJSON = jsonFile.readJson
jsonFile.readJSONSync = jsonFile.readJsonSync
module.exports = jsonFile
'use strict'
const u = require('universalify').fromCallback
const mkdirs = u(require('./mkdirs'))
const mkdirsSync = require('./mkdirs-sync')
module.exports = {
mkdirs,
mkdirsSync,
// alias
mkdirp: mkdirs,
mkdirpSync: mkdirsSync,
ensureDir: mkdirs,
ensureDirSync: mkdirsSync
}
exports.write = function (fd, buffer, ...args) {
if (typeof args[args.length - 1] === 'function') {
return fs.write(fd, buffer, ...args)
}
return new Promise((resolve, reject) => {
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
if (err) return reject(err)
resolve({ bytesWritten, buffer })
})
})
}
// fs.realpath.native only available in Node v9.2+
if (typeof fs.realpath.native === 'function') {
exports.realpath.native = u(fs.realpath.native)
}
'use strict'
const u = require('universalify').fromCallback
const jsonFile = require('jsonfile')
module.exports = {
// jsonfile exports
readJson: u(jsonFile.readFile),
readJsonSync: jsonFile.readFileSync,
writeJson: u(jsonFile.writeFile),
writeJsonSync: jsonFile.writeFileSync
}
supportsFallback: true,
resizeToFontSize: false,
trim: false,
trimTolerance: 10,
attrs: {},
textToSvg: {
x: 0,
y: 0,
anchor: 'left top',
attributes: {
stroke: 'none'
}
}
};
const load = universalify.fromCallback(TextToSvg.load);
function setDefaults(options) {
defaults = _.defaultsDeep(options, defaults);
return defaults;
}
// eslint-disable-next-line complexity
async function setOptions(options) {
// Clone to prevent interference
options = _.cloneDeep(options);
// Set deep defaults
options = _.defaultsDeep(options, defaults);
// Ensure `text` is a string
if (!_.isString(options.text)) throw new Error('`text` must be a String');
const request = require('request')
const hms = require('hh-mm-ss')
const http = require('http')
const url = require('url')
const {
isYouTubeRegex,
isWin,
formatDuration,
has,
isString
} = require('./util')
let ytdlBinary = require('./get-binary')()
const execa = universalify.fromPromise(require('execa'))
function youtubeDl (args, options, cb) {
return execa(ytdlBinary, args, options, function done (err, { stdout }) {
if (err) return cb(err)
return cb(null, stdout.trim().split(/\r?\n/))
})
}
/**
* Processes data
*
* @param {Object} data
* @param {Object} options
* @param {Object} stream
*/
api.forEach(method => {
exports[method] = u(fs[method])
})
'use strict'
const u = require('universalify').fromCallback
const rimraf = require('./rimraf')
module.exports = {
remove: u(rimraf),
removeSync: rimraf.sync
}
'use strict'
const u = require('universalify').fromCallback
module.exports = {
copy: u(require('./copy'))
}
'use strict'
const u = require('universalify').fromCallback
module.exports = {
move: u(require('./move'))
}