fairfieldt / coffeescript-concat Goto Github PK
View Code? Open in Web Editor NEWA utility that preprocesses and concatenates CoffeeScript source files
License: Other
A utility that preprocesses and concatenates CoffeeScript source files
License: Other
Hi, firstly thanks for sharing this lib, it's very usefull.
I have a feature request "it will be great to automatically run concat on file-change"
I cannot include a folder with a name longer than one letter.
I try to include to folder coffee\maze and the folder c does not exists ... that is true, it's name coffee, not c.
If I rename the folder 'coffee' to 'c' then the error is the same, just with m instead of c.
[some path]>coffeescript-concat -I coffee\maze test.coffee -o main.coffee
fs.js:654
return binding.readdir(pathModule._makeLong(path));
^
Error: ENOENT, no such file or directory '[some path]\c'
at Object.fs.readdirSync (fs.js:654:18)
at [NPM-Path]\node_modules\coffeescript-concat\coffeescript-concat:60:19
at mapDependencies ([NPM-Path]\node_modules\coffeescript-concat\coffeescript-concat:67:9)
at concatenate ([NPM-Path]\node_modules\coffeescript-concat\coffeescript-concat:202:12)
at Object.<anonymous> ([NPM-Path]\node_modules\coffeescript-concat\coffeescript-concat:224:3)
at Object.<anonymous> ([NPM-Path]\node_modules\coffeescript-concat\coffeescript-concat:226:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
My coffeescript application depends on jquery and batman.js that are inserted as separate files.
So my classes extend different Batman.Object with Batman's naming rules i.e:
class Chat.Message extends Batman.Model
When I concat them with coffeescript-concat I get tones of "Error: couldn't find needed class: Batman"
What should I do to switch that warnings off as I do not want to concat my files with batman.js?
It will be great to have tasks for grunt.
May be I can create grunt-coffeescript-concat repository and use your code for grunt tasks.
I didn't find any doc, so I don't know how handles paths.
How to make it work?
I want to use something like this files:
main.coffee
#= require <ClassA.coffee>
#= require <ClassB.coffee>
#= require <NamespaceX/main.coffee>
# ...
NamespaceX/main.coffee
#
#= require <ClassA.coffee>
#= require <ClassB.coffee>
# ...
In a tree like:
NamespaceX
ClassA.coffee
ClassB.coffee
main.coffee
ClassA.coffee
ClassB.coffee
main.coffee
Then run something like:
coffeescript-concat main.coffee
...and compiles together.
In #= require <FILE>
... FILE should be full path or relative to file?
Using coffeescript-concat with phpstorm on a filewatcher the output is appended to rather than overwritten. Is this intended functionality? How can I overwrite?
I'm just using the following args : '-R
It would be nice to have coffeescript maps supports, I mean to be able to get separate files on debugging of the concatenated one.
1.0.6 is not working if i put something like this
coffee ./node_modules/coffeescript-concat/coffeescript-concat.coffee -I ./src/ -o ./src_cof/<%= pkg.name %>.coffee
1.0.5 is working with the same command
I think this commit made this bug 5d91c98
I'm trying to use this with Backbone.js and have some of my CoffeeScript models extend Backbone.Model. But if I do this, I get something like "Error: couldn't find needed class: Backbone". It'd be nice to support this use case and somehow assume that Backbone.Model would be defined ahead of time. Either flat out ignore "couldn't find this class" errors, or potentially pass a whitelist of classes that CoffeeScript-Concat should assume will already be defined.
Thanks!
The failure is because mapDependencies(sourceFiles, searchDirectories) in cofeescript-concat.coffee line 82 expects searchDirectories to be an array. But if you only pass a single include dir then searchDirectories will be a string instead. This causes "fs.readdirSync(dir)" on line 85 to fail because dir will be a single character from the string instead of a valid path.
This is for v1.0.2 installed via npm on Ubuntu 11.04
Workaround:
pass multiple include dirs: "coffeescript-concat -I ./src/somedir -I /src/dummydir -o ./src/foo.coffee input.coffee another_input.coffee"
Real Fix:
include a check of searchDirectories' type inside mapDirectories. Something like this in coffeescript-concat.coffee lines 85-89
sdtype = typeof searchDirectories
switch sdtype
when 'array'
for dir in searchDirectories
files = files.concat(path.join(dir, f) for f in fs.readdirSync(dir))
when 'string'
files = files.concat(path.join(dir, f) for f in fs.readdirSync(dir))
Here's the raw javascript that I hacked up on my local install (coffeescript-concat, lines 56-83):
if (typeof (searchDirectories) === 'array') {
// if more than one include dir then grab everything from all include dirs
for (_i = 0, _len = searchDirectories.length; _i < _len; _i++) {
dir = searchDirectories[_i];
files = files.concat((function() {
var _j, _len2, _ref, _results;
_ref = fs.readdirSync(dir);
_results = [];
for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
f = _ref[_j];
_results.push(path.join(dir, f));
}
return _results;
})());
}
} else if (typeof (searchDirectories) === 'string') {
// if only one include dir was specified then simply grab everything inside there
files = files.concat ((function () {
var results = fs.readdirSync (searchDirectories);
for (var i = 0; i < results.length; i++) {
results[i] = path.join (searchDirectories, results[i]);
}
return results;
})());
} else {
// no include dirs specified, so do nothing
}
For a node project, I would like to have my index.coffee file using to do like such:
#= require <vendor>
#= require <functions>
(($) ->
#= require <form-elements>
#= require <main-site>
) jQuery
Unfortunately, instead of going where I expect them to go, they end up at the top of the file - which is the programmed intended action, but not what I am looking for.
I would like to be able not to always write the ready function for all files.
Is there a way to compile/concat coffeescript that can put included files at specific positions, say inside a function?
When I put requere to the file that I want to concat (the file mock.coffee is in the same directory)
I get "Error: couldn't find needed class: mock"
Why does it search for class when I want file to be included? I have several classes inside this file and some of them have compound names, i.e. Chat.Mock
Does any coffeescript-concat integration with gulp exist?
Or maybe it's better just use gulp-grunt + coffeescript-concat grunt plugin for integration with gulp?
If I execute coffeescript-concat -I . 1.coffee
on https://gist.github.com/anonymous/cb501902e65a1831bce7, the #= require is retained as-is instead of being replaced by the contents of 2.coffee
Hello,
I have the following situation:
#= require Bar
class FooBar extends Bar
some: () -> console.log(@)
class Bar
someOther: () -> console.log(@)
$(->)
Then I use this command: coffeescript-concat -I classes/ application.coffee
class Bar
someOther: () -> console.log(@)
class FooBar extends Bar
some: () -> console.log(@)
$(()->)
Because I have no require statement in application.coffee, I want to have this result:
$(()->)
Hi, I'm interested in using your project, is there a license for the code?
coffeescript-concat lacks a license. If it's open-source (which I assume it is) make it obvious! I'm working on a few features, namely adding watch support, so it would be cool if I could merge them back into coffescript-concat when I'm done!
Should it instead say the following?
Using coffeescript-concat:
Using npm:
$ npm install -g coffeescript-concat
$ coffeescript-concat -I /my/include/directory -I includeDir2 A.coffee B.coffee -o output.coffee
Using CoffeeScript directly:
$ coffee coffeescript-concat.coffee -I /my/include/directory -I includeDir2 A.coffee B.coffee -o output.coffee
This will preprocess and concatenate T
I've installed node.js, coffee, and underscore, but when I run coffee coffeescript-concat.coffee
I get the following error:
Error: couldn't find needed class: ClassName
Error: couldn't find needed class: directives
Error: couldn't find needed file: FileName
Google's not helping on what's missing unfortunately. I'm guessing something obvious?
The 'mapDependencies' method does not require search directories, but the command line arguments are fixed to enforce that at least 2 args are required. Basically, in the simple case when I am passing in two files I should not have to specify an include directory as well.
See pull request: #9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.