Skip to content

Instantly share code, notes, and snippets.

@MhdAljuboori
Last active August 16, 2019 14:07
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MhdAljuboori/f917915fd586ab40cc44 to your computer and use it in GitHub Desktop.
Save MhdAljuboori/f917915fd586ab40cc44 to your computer and use it in GitHub Desktop.
NG-Annotate for folder
var sh = require('shelljs');
function annotateFile (filePath) {
console.log('annotate ' + filePath);
sh.exec('ng-annotate -a ' + filePath + ' -o ' + filePath);
}
function annotateFolder (folderPath) {
console.log("annotate Folder " + folderPath);
sh.cd(folderPath);
var files = sh.ls() || [];
for (var i=0; i<files.length; i++) {
var file = files[i];
if (file.match(/.*\.js$/))
annotateFile(file);
else if (!file.match(/.*\..*/)) {
annotateFolder(file);
sh.cd('../');
}
}
}
if (process.argv.slice(2)[0])
annotateFolder(process.argv.slice(2)[0]);
else {
console.log('There is no folder');
console.log('--- node FILENAME.js FOLDER_PATH');
}
@MhdAljuboori
Copy link
Author

Usage

You must already install NodeJS

Install shelljs and ng-annotate

$ npm install shelljs
$ npm install -g ng-annotate

Now you can use this script by typing in Terminal

$ node ng-an-folder FOLDER_PATH

@kevinboosten
Copy link

Thanks, just needed to annotate my legacy angularjs app only once so I could integrate it into my Angular stack.

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