Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2016 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6f7985c318d0eda16ebd6c1b1a7726e7 to your computer and use it in GitHub Desktop.
Save anonymous/6f7985c318d0eda16ebd6c1b1a7726e7 to your computer and use it in GitHub Desktop.
<cfscript>
function verifyCompile(mapping){
var pathtoSourceCode = expandPath(arguments.mapping);
var files = directoryList(path=pathtoSourceCode, recurse=true, filter="*.cf*");
var passedFiles = [];
var failedFiles = [];
var failedErrors = {};
for(f in files){
try {
getPageContext().compile(contractPath(f));
passedFiles.append(f);
}
catch(Any e){
failedErrors[f] = e;
failedFiles.append(f);
}
}
return { "errors"=failedErrors, "passedFiles"=passedFiles, "failedFiles"=failedFiles };
}
</cfscript>
@cybersonic
Copy link

Much better! Mine was a simple example but this could be a nice BIF

@JamoCA
Copy link

JamoCA commented Jan 27, 2021

Is this Lucee-only code?

getPageContext().compile() doesn't appear to be available in Adobe ColdFusion. Is there a java function that will work with ACF?

Adobe's directoryList() doesn't support named parameters unless using CF2018+. According to a 2013 CF10 bug report, this issue was closed & considered trivial. It wasn't fixed until CF2018 even though CF2016 is not end-of-life yet.
https://tracker.adobe.com/#/view/CF-3540467

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment