tasks/applymin.js
function (targetFilePath, abspaths) {
    // Change 'assets/mdeditor.min.js' to 'assets/' and 'mdeditor.min.js'
    var pathFilename = _splitPathAndFilename(targetFilePath);
    var targetPath = pathFilename[0];
    var targetFilename = pathFilename[1];

    // bug fix: assets/xxxxxxxx.mdeditor.min.js, xxxxxxxx can't contain '/' or white character
    // otherwise 'assets/mdeditor/1111.mmm.min.js' matched target filename: 'assets/mmm.min.js', which is incorrect.
    var filenamePattern = new RegExp(targetPath + '[^\\/\\s]+?\\.' + targetFilename);

    // Find the revision file based on targetFilePath defined in html template, if there are multiple files matched, pick up the latest one.
    var revTargetFilePath = null;
    var revTargetFileModifyTime = null;
    for (var index in abspaths) {
        if (abspaths[index].match(filenamePattern)) { // there could be more than one revision files matched filenamePattern
            // match the first revision file.
            if (revTargetFilePath === null) {
                revTargetFilePath = abspaths[index];
            // match the one more revision files, pick up the latest files.
            } else {
                if (revTargetFileModifyTime === null) {
                    revTargetFileModifyTime = fs.lstatSync(revTargetFilePath).mtime;
                }
                var currentFileModifyTime = fs.lstatSync(abspaths[index]).mtime;
                if (currentFileModifyTime > revTargetFileModifyTime) {
                    revTargetFilePath = abspaths[index];
                    revTargetFileModifyTime = currentFileModifyTime;
                }
            }
        }
    }
    if (revTargetFilePath === null) {
        grunt.warn('In the file: ' + templateFilename + ', the target filename: ' + targetFilePath + ' has not been handled to produce a corresponding revision file.');
    }
    return revTargetFilePath;
  }
function (targetFilePath, abspaths) {
    // Change 'assets/mdeditor.min.js' to 'assets/' and 'mdeditor.min.js'
    var pathFilename = _splitPathAndFilename(targetFilePath);
    var targetPath = pathFilename[0];
    var targetFilename = pathFilename[1];

    // bug fix: assets/xxxxxxxx.mdeditor.min.js, xxxxxxxx can't contain '/' or white character
    // otherwise 'assets/mdeditor/1111.mmm.min.js' matched target filename: 'assets/mmm.min.js', which is incorrect.
    var filenamePattern = new RegExp(targetPath + '[^\\/\\s]+?\\.' + targetFilename);

    // Find the revision file based on targetFilePath defined in html template, if there are multiple files matched, pick up the latest one.
    var revTargetFilePath = null;
    var revTargetFileModifyTime = null;
    for (var index in abspaths) {
        if (abspaths[index].match(filenamePattern)) { // there could be more than one revision files matched filenamePattern
            // match the first revision file.
            if (revTargetFilePath === null) {
                revTargetFilePath = abspaths[index];
            // match the one more revision files, pick up the latest files.
            } else {
                if (revTargetFileModifyTime === null) {
                    revTargetFileModifyTime = fs.lstatSync(revTargetFilePath).mtime;
                }
                var currentFileModifyTime = fs.lstatSync(abspaths[index]).mtime;
                if (currentFileModifyTime > revTargetFileModifyTime) {
                    revTargetFilePath = abspaths[index];
                    revTargetFileModifyTime = currentFileModifyTime;
                }
            }
        }
    }
    if (revTargetFilePath === null) {
        grunt.warn('In the file: ' + templateFilename + ', the target filename: ' + targetFilePath + ' has not been handled to produce a corresponding revision file.');
    }
    return revTargetFilePath;
  }
function ( targetFilePath , abspaths ) { // Change 'assets/mdeditor.min.js' to 'assets/' and 'mdeditor.min.js' var pathFilename = _splitPathAndFilename ( targetFilePath ) ; var targetPath = pathFilename [ 0 ] ; var targetFilename = pathFilename [ 1 ] ; // bug fix: assets/xxxxxxxx.mdeditor.min.js, xxxxxxxx can't contain '/' or white character // otherwise 'assets/mdeditor/1111.mmm.min.js' matched target filename: 'assets/mmm.min.js', which is incorrect. var filenamePattern = new RegExp ( targetPath + '[^\\/\\s]+?\\.' + targetFilename ) ; // Find the revision file based on targetFilePath defined in html template, if there are multiple files matched, pick up the latest one. var revTargetFilePath = null ; var revTargetFileModifyTime = null ; for ( var index in abspaths ) { if ( abspaths [ index ] . match ( filenamePattern ) ) { // there could be more than one revision files matched filenamePattern // match the first revision file. if ( revTargetFilePath === null ) { revTargetFilePath = abspaths [ index ] ; // match the one more revision files, pick up the latest files. } else { if ( revTargetFileModifyTime === null ) { revTargetFileModifyTime = fs . lstatSync ( revTargetFilePath ) . mtime ; } var currentFileModifyTime = fs . lstatSync ( abspaths [ index ] ) . mtime ; if ( currentFileModifyTime > revTargetFileModifyTime ) { revTargetFilePath = abspaths [ index ] ; revTargetFileModifyTime = currentFileModifyTime ; } } } } if ( revTargetFilePath === null ) { grunt . warn ( 'In the file: ' + templateFilename + ', the target filename: ' + targetFilePath + ' has not been handled to produce a corresponding revision file.' ) ; } return revTargetFilePath ; }
Get the revTargetFilePath based on targetFilePath.
Get the revTargetFilePath based on targetFilePath .