Tag: coffeescript

如何扩展'应该'图书馆

我想介绍应该断言图书馆,工作testing我的node.js应用程序,我的附加function。 就像这个伪代码一样 should = require "should" myExists = (obj, msg) -> # my special exist logic containSomething = (obj, msg) -> # my special assert logic should.myExists = myExists should.containSomething = containSomething describe.only "`my extra `", -> it 'should be working', (done) -> obj = {} obj.should.myExists obj.should.not.myExists obj.should.containSomething {cool:obj} obj.should.not.containSomething {cool:obj} done() 任何build议如何在实践中做到这一点?

咕噜咕噜地看着咖啡和玉石文件

我想同时观看我的咖啡和咕噜声文件。 当我只是看咖啡文件没有问题,但是当我添加一个玉观察员到我的文件观察员只编译一次 ,虽然有一个更新,观察员没有编译这些新的更新。 任何帮助表示感谢: 这里是我的系统中只有咖啡监视器的时候: 每当咖啡文件有更新时编译: Gruntfile.coffee module.exports = (grunt) -> grunt.initConfig pkg : grunt.file.readJSON "package.json" coffee : compile : options : sourceMap: on files : ['dist/client/js/main.js': 'client/app/scripts/app.coffee', 'server.js': 'server.coffee'] watch : coffee : options : atBegin: yes files : [ 'client/scripts/*.coffee', 'client/scripts/controllers/*.coffee', 'server.coffee'] tasks : ['coffee', 'jade'] grunt.loadNpmTasks 'grunt-contrib-coffee' grunt.loadNpmTasks 'grunt-contrib-watch' grunt.registerTask 'default', ['watch'] […]

NodeJS Browserify:将uglifyfy与源地图一起使用在coffeeify中

目前,当我使用browserify和coffeeify源地图工作完美。 但是,当我添加uglifyify的另一个变换时,源映射被遮住到缩小的JavaScript。 是否有可能使用这两个变换,并通过从coffeeify到uglifyify sourcemap? 这里是我的观点browserify: -d -t coffeeify -g uglifyify –extension=".coffee" -e "main.coffee" -o "bundle.js" 另外,当我问,有没有人知道如何要求模块,我已经安装全球节点? Browserify似乎只查看本地node_modules文件夹,而不是全局的。

用Jade编译Coffeescript:咖啡filter:会妨碍性能吗? 有没有办法简化? 裸?

我正在考虑通过jade的咖啡filter来编译客户端的coffeescript。 Express的设置很简单,如下所示(在我通过命令行编译的coffeescript中): app.get '/coffee/:script', (req, res) -> script = req.params.script res.render "../coffee/#{script}" .jade文件可以是: :coffee console.log 'hello world' 我有三个问题: 有没有任何性能问题,我应该关心与通过命令行预编译脚本? 我假设在服务器启动(或第一次加载?),他们可能会花更less的时间,但应该被caching? 有没有办法让玉石自动呈现整个文件应该是:咖啡文字? 这将节省:咖啡线,并从每行的额外缩进。 有没有办法让玉编译脚本光秃秃的(function(){包装?我经常写自己的: (($)-> … ) jQuery ,有时需要公开variables:)

在Webstorm / Intellij中debuggingCoffeescript jasmine-nodetesting

我正在使用节点 – 茉莉花2testing版,并写在咖啡的脚本。 我很高兴地在Intellij 13.1中运行testing,并设置了以下运行configuration Node interpreter: /usr/local/bin/node Working Dir: [Project Directory] Javascript File: node_modules/jasmine-node/bin/jasmine-node Application Parameters: –coffee –verbose spec 我也为我所有的coffeescript文件设置了文件监视器,并且它们正在正确构build并放入[Project Directory]/.build /。build子目录 大! 但是在debugging时设置断点不起作用。 发回给Intellij的信息似乎引用了javascript文件,给出了我所看到的行号,表明sourcemaps没有被正确引用。 谁能帮忙? (目前我通过添加一个debugger语句,而不是intellij的断点)

用hapi随时编译coffeescript?

是否有一个hapi的插件,可以根据需要将coffeescript编译成JS? 我知道连接咖啡脚本和咖啡中间件 ,只是寻找与hapi,我相信不是build立在连接上的作品。

我如何得到Guard来自动编译我的Coffeescript文件? 说是的,但不是

我有以下Guardfile coffeescript_options = { input: 'src/js', output: 'www/js', patterns: [%r{^src/js/(.+\.(?:coffee|coffee\.md|litcoffee|js))$}] } guard 'coffeescript', :input => 'src/js', :output => 'www/js' do coffeescript_options[:patterns].each { |pattern| watch(pattern) } end # guard 'coffeescript', :input => 'src/js', :output => 'www/js' 我保存了src/js/tf.coffee文件并logging下来 02:46:50 – INFO – Compile src/js/tf.coffee 02:46:50 – INFO – 02:46:50 AM Successfully generated ←]2;[CoffeeScript results] Successfully generated 但是,我无法在任何地方find该文件。 […]

把Gulp的消息传递给gulp-coffee,gulp-concat和webpack-stream

我有这个代码: var gulp = require('gulp'); var webpack = require('webpack-stream'); var coffee = require('gulp-coffee'); var concat = require('gulp-concat'); gulp.task('webpack', function() { gulp.src('*/lib/*.coffee', { base: '.' }) .pipe(coffee({ bare: true })) .pipe(concat('app.js')) .pipe(webpack()) .pipe(gulp.dest('.')); }); 但是,它到达webpack()时webpack() 。 我怎样才能使从concat()传递给webpack()成功运行? 我还假设,如果我删除了concat()pipe道,并直接从coffee()到webpack() ,那么我最终会得到由webpack()处理的多个文件,而不是一个单一的,对吧? 我尝试使用Webpack的coffee-loader ,但由于某些原因,它输出内容bare: false (当我看着输出文件),即使在实际的包,它似乎是硬编码输出bare: true 。 所以这就是为什么我使用gulp-coffee 。

从节点导入Coffeescript v2

我正在尝试从Node.js文件导入Coffeescript v2模块。 我已经安装了coffeescript v2( coffeescript@next ),但是我无法在coffeescript和javascript文件之间导出/导入。 我的代码是: // index.js require("coffeescript/register") require('babel-register') require("./server.js") // server.js import Foo from "./example.coffee" // example.coffee console.log("qwe") console.log "abc" export default a = 2 node index.js失败 …/example.coffee:7 export default a = 2; ^^^^^^ SyntaxError: Unexpected token export at createScript (vm.js:74:10) at Object.runInThisContext (vm.js:116:10) at Module._compile (module.js:533:28) at Object.loadFile (/home/petr/mern-informatics-test/node_modules/coffeescript/lib/coffeescript/register.js:16:19) at Module.load […]

AMQP使用Node.js,我如何发布/订阅?

我正在做一个类来操作这里提供的Node-AMQP模块: https : //github.com/postwait/node-amqp 但是我不能使用这个发布/订阅: var Queue = require('./Queue.js'); var queue = new Queue(); queue.addTaskToQueue('salut', 5); queue.subscribeTaskQueue('salut'); 这里是我正在使用的类(我在CoffeeScript中给出代码,在Node.js中给那些不知道CoffeeScript的人): 谢谢你的帮助。 在CoffeeScript中: amqp = require('amqp') class Queue constructor: (ip = 'localhost') -> @ip = ip @receivedObject @connection = amqp.createConnection({ host: @ip }) @queue subscribeTaskQueue: (queueToSubscribe) -> self = @ self.connection.on('ready', -> q = self.connection.queue(queueToSubscribe) q.bind('#') q.subscribe({ ack: […]