CoffeeScript - copy order in subdirectories

Is there a way to determine how CoffeeScript compiles in subdirectories? Please consider the following example:

Files:

  • CSI /App.coffee
  • SIC / view / B.coffee
  • CSI / view / a / A.coffee

If class A extends B.

coffee --join js/app.js --compile src/view/ src/App.coffee

This causes a browser error:

Uncaught TypeError: Cannot read property 'prototype' of undefined 

If I rename folder a to z , the error will disappear and everything will be fine.

  • Src / view / g / A.coffee

I would expect the compiler to read all .coffee files from src / view / before it goes into src / view / sub-directories. Again, is there a way to do this?

Edit: Windows 7 PC, CoffeeScript version 1.3.3

+5
source share
2 answers

, , - script. , , , .

Cakefile , . cake build. , CoffeeScript.

fs = require 'fs'
{exec} = require 'child_process'

viewsDir = "src/view"
coffeeFiles = [
  'B'
  'A'
]

task 'build'
  # loops through coffeeFiles. 
  for file, index in coffeeFiles then do (file, index) ->
    fs.readFile "#{viewsDir}/#{file}", 'utf8', (err, content) ->
      appCoffee[index] = content
      compile() if --remaining is 0

  compile = ->
    fs.writeFile 'js/app.coffee', appCoffee.join('\n\n'), 'utf8', (err)   ->
      throw err if err
      exec 'coffee --compile js/app.coffee', (err, stdout, stderr) ->
        throw err if err
          console.log stdout + stderr

          # you can skip deleting the app.coffee file
          fs.unlink 'js/app.coffee', (err) ->
            throw err if err
            console.log 'Created app.coffe, compiled to app.js and removes app.coffee'

            # maybe additional taks 
            # invoke 'test'

Wiki of Coffeescript https://github.com/jashkenas/coffee- script/wiki/[HowTo] -Compiling-and- -Build-Tools

. , , , fs.readDir().

+5

:

https://github.com/Vizir/rehab

#_require [filename].coffee , .

.

+2

All Articles