How to order files collected using a coffee rack

I would like to be able to include a file in a given order by compiling coffeescript files in js using the coffee bar.

I would like to have settings.coffee , constants.coffee files included first

 -- |-- settings.coffee |-- constants.coffee |-- page1.coffee |-- page2.coffee 

Code snippet

 fs = require 'fs' {exec, spawn} = require 'child_process' util = require 'util' task 'watch', 'Coffee bar Combine and build', -> coffee = spawn 'coffeebar', ['-w','-o','./../js/main/kc.js', './'] coffee.stdout.on 'data', (data) -> console.log data.toString().trim() invoke 'minify' task 'minify', ' Minify JS File', -> file = "./../js/main/kc" util.log "Minifiying #{file}.js" exec "uglifyjs #{file}.js > #{file}.min.js", (err,stdout,stderr) -> if err util.log "Error minifiying file" util.log err else util.log "Minified to #{file}.min.js" util.log '----------------------------' 

So far, the script has put everything together in accordance with its logic.

I would appreciate any help with this.

+7
javascript coffeescript exec minify spawn
source share
1 answer

You seem to have 3 potential solutions, but all of them are not so elegant:

  • I'm not sure, but I will try to set the argument inputPaths coffeebar(inputPaths, [options]) as an explicit array of paths with file names, where you can set the order of the elements of the array as needed

  • try renaming files with num prefixes like 01_settiings.coffee, etc., so that you need it, so the coffee maker will process it in that order

  • you can use an additional plugin, for example rigger , to include all the files in the desired sequence in one root file and process this file with a coffee maker

+2
source share

All Articles