Skip to content

Commit

Permalink
✨ Allow Alchemy#getFileInfo() to be supplied a filename
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Feb 15, 2024
1 parent fde29bd commit 7baa4af
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/core/alchemy_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ Alchemy.setMethod(function statPath(path, options) {
*
* @author Jelle De Loecker <[email protected]>
* @since 0.0.1
* @version 1.3.0
* @version 1.4.0
*
* @param {string} filePath A path to the file
* @param {Object} options
Expand Down Expand Up @@ -904,11 +904,15 @@ Alchemy.setMethod(function getFileInfo(filePath, options, callback) {
tasks.hash = this.hashFile(filePath, options.hash);
}

// Get the filename
tasks.filename = function getFilename(next) {
var pieces = filePath.split('/');
next(null, pieces[pieces.length-1]);
};
if (options.filename) {
tasks.filename = options.filename;
} else {
// Get the filename
tasks.filename = next => {
let pieces = filePath.split('/');
next(null, pieces[pieces.length-1]);
};
}

// Get the extension
tasks.extension = function getExtension(next) {
Expand Down

0 comments on commit 7baa4af

Please sign in to comment.