ensure-ffmpeg
Advanced tools
Comparing version 1.0.0 to 1.0.1
27
index.js
@@ -8,10 +8,23 @@ const fs = require('fs-extra'); | ||
function removeFFMPEGFolder(tempFolder) { | ||
let files = fs.readdirSync(tempFolder); | ||
files.filter(file => file.startsWith('ffmpeg-')).forEach(file => fs.removeSync(path.join(tempFolder, file))); | ||
if (fs.existsSync(tempFolder)) { | ||
let files = fs.readdirSync(tempFolder); | ||
files.filter(file => file.startsWith('ffmpeg-')).forEach(file => fs.removeSync(path.join(tempFolder, file))); | ||
} | ||
} | ||
function ensureFFMPEG(tempFolder, ffmpegPath) { | ||
ffmpegPath = ffmpegPath || path.join(__dirname, 'ffmpeg.exe'); | ||
tempFolder = tempFolder || path.join(__dirname, 'temp'); | ||
/** | ||
* Ensure ffmpeg utility is available in root folder | ||
* @param {string} rootPath Root path of executing folder, default: __dirname | ||
* @param {string} tempFolder Temporary folder for downloads, default: 'temp' (will be cleared) | ||
*/ | ||
function ensureFFMPEG(rootPath, tempFolder) { | ||
rootPath = rootPath || | ||
__dirname.endsWith('node_modules\\ensure-ffmpeg') || __dirname.endsWith('node_modules/ensure-ffmpeg') ? | ||
__dirname.substr(0, __dirname.length - 'node_modules/ensure-ffmpeg'.length) : | ||
__dirname; | ||
ffmpegPath = ffmpegPath || path.join(rootPath, 'ffmpeg.exe'); | ||
tempFolder = tempFolder || path.join(rootPath, 'temp'); | ||
if (!fs.existsSync(ffmpegPath)) { | ||
@@ -21,3 +34,3 @@ | ||
download(downloadUrl, tempFolder, { extract: true, filename: 'ffmpeg' }) | ||
return download(downloadUrl, tempFolder, { extract: true, filename: 'ffmpeg' }) | ||
.then(() => { | ||
@@ -37,4 +50,6 @@ let files = fs.readdirSync(tempFolder); | ||
} | ||
return new Promise.resolve(); | ||
} | ||
module.exports = { ensureFFMPEG } |
{ | ||
"name": "ensure-ffmpeg", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Ensure ffmpeg is avialable on the local environment", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2222
39