 Command line based build [tools](https://hackernoon.com/tagged/tools) gain a lot of attention in the JavaScript world recently. They are straightforward, flexible and quite easy to manage compare to verbose Grunt.js/Gulp.js files and workflows. This goes with the way of being agile and adaptable which is more and more important in the fast changing [JavaScript](https://hackernoon.com/tagged/javascript) world. But which command line based build tool to choose ? What’s the differences between them ? ### Quick sum up of complex build systems _Main disadvantages:_ * **Dependence on plugins** and their documentation. They are not always up to date, can break later and cause pain with the debugging. Docs are spread out across different projects and finding things which you are looking for can be really hard. * **Bloat**. It’s very common to end up with Gruntfile or Gulpfile which has hundreds of lines of code. Code is hard to understand, maintain and trying custom solutions is very challenging. It requires a lot of knowledge about the building system. Whole approach seems to be over-engineered and unnecessary complex. _Further reading:_ [**Why we should stop using Grunt & Gulp** _If you're building a modern JavaScript application or website, there's a good chance you've seen the JavaScript Build…_www.keithcirkel.co.uk](https://www.keithcirkel.co.uk/why-we-should-stop-using-grunt/ "https://www.keithcirkel.co.uk/why-we-should-stop-using-grunt/")[](https://www.keithcirkel.co.uk/why-we-should-stop-using-grunt/) [**Why I Left Gulp and Grunt for npm Scripts** _I know what you’re thinking. WAT?! Didn’t Gulp just kill Grunt? Why can’t we just be content for a few minutes here in…_medium.freecodecamp.com](https://medium.freecodecamp.com/why-i-left-gulp-and-grunt-for-npm-scripts-3d6853dd22b8 "https://medium.freecodecamp.com/why-i-left-gulp-and-grunt-for-npm-scripts-3d6853dd22b8")[](https://medium.freecodecamp.com/why-i-left-gulp-and-grunt-for-npm-scripts-3d6853dd22b8) ### Simple build tools We have 3 candidates: _npm scripts_, _Makefile_ and [_runjs_](https://github.com/pawelgalazka/runjs). All of those are based on command line scripting. You don’t need much of knowledge about those tools. They are very easy with their construction and workflow. What is important is how you can effectively manage command line scripts. _Main advantages_: * shallow learning curve * easy customisation, flexibility * plugins are not needed, cli commands are powerful enough ### npm scripts Built-in feature into npm package manager. Content of each task is held in _package.json_ under “scripts” section. Each task can be called by _npm run \[task-name\]_ command. \[[More](https://docs.npmjs.com/misc/scripts)\]. _Pros:_ * you don’t need to install additional tools, _npm scripts_ are part of _npm,_ so you are ready to go right away * hook scripts, which can be run in specific situations, like _prepublish_, _postinstall_ or _pretest_ _Cons:_ * when scripts get complex they are hard to read * introducing more complex logic like conditional checks, errors or argument handling can be problematic to implement and maintain * you can’t use JavaScript code unless you export it to a separate script file * it’s hard to document tasks Obviously you can reduce those cons by extracting commands from scripts section to separate files (bash/node scripts) and call them in npm scripts. In the end it’s not necessary convenient though as you will have your build code spread out across multiple files. For tasks up to 15/20 lines of code which are quite frequent it can feels just too much. Moreover if you want to use ES6/7, ES6 imports in your node.js build scripts you need to compile them. That complicate the process unnecessary. _Example of npm scripts usage:_ _Example of calling a task:_ npm run watch:test ### Makefile Build automation tool created by [Stuart Feldman](https://en.wikipedia.org/wiki/Stuart_Feldman) and initially released in 1977. With the main purpose for C/C++ code compilation. However thanks to its flexibility it started to gain more universal usage. It allows to define tasks in “Makefile” file. Tasks can be called by _make_ command in the terminal. \[[More](https://www.gnu.org/software/make/manual/make.html)\]. _Pros:_ * implementing more complex logic is not an issue * good readability * you don’t need to install additional tools (unless you are Windows user), _make_ should be already present in the unix environment _Cons:_ * you are tied to shell code, you can’t use JavaScript which you already know * this means that sometimes shell code can be hard to deal with. Additional learning curve for complex logic. _Example of Makefile:_ Example of calling a task: make test ### runjs Written in JavaScript. Minimalistic build tool. Can be installed through npm. Allows to define tasks in “runfile.js” file. Tasks can be called by _run_ (or _npx run_) command in the terminal. \[[More](https://github.com/pawelgalazka/runjs)\]. _Pros:_ * **you can use JavaScript** within tasks (with ES6/7) and import other npm modules. _runfile.js_ is just a JavaScript module. This allows **massive flexibility**. * you can do command line calls also, by _run_ function * good readability * it handles task arguments easily _Cons:_ * global _run_ command which needs to be installed through _npm -g runjs-cli._ This can be avoided in node ≥ 8.2, where you can call _runjs_ tasks through _npx_, like “npx run dev_”._ [More about npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b). _Example of runfile.js_: _Example of calling a task:_ run test run lint components/App.js --fix run build:clean ### Conclusions I would say that considering the simple build tooling, all of those 3 are really good. The main difference is within the relation between flexibility and readability. In that matter _runjs_ seems to be the strongest. For further experimenting I give you a couple of interesting examples which are easy to do in _runjs_ but can be hard to manage in _npm scripts_ or _Makefile_. _Documenting tasks:_ **$ run build --help** _Sharing tasks to a npm package:_ **$ run shared** _Accepting arguments and conditional checks:_ **$ run test sidebar/button.js browser** _Error handling and fallbacks:_ **$ run build** _Handling async calls:_ **$ run start** [**runjs** _Minimalistic building system_www.npmjs.com](https://www.npmjs.com/package/runjs "https://www.npmjs.com/package/runjs")[](https://www.npmjs.com/package/runjs)