Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Random fixes required when I first checked out the project. #105

Merged
merged 8 commits into from

4 participants

@my8bird

The only thing I see that could be problematic (through my naive eyes) would be the redis package as a dependency. In order to run the project redis is required so it seemed that this needed to be there.

Otherwise, this ensures that cake uses the projects coffee executable instead of the system wide one and adds some hooks to ensure the lib directory is up to date at crucial points.

@wmertens
Collaborator

Actually the redis dependency is optional... And if the system wide coffee matches the required version it won't be installed locally. It would be better to define a PATH that includes the node_modules here as well as the normal path and just call coffee. That way the shell will use the first one it finds.

@wmertens wmertens closed this
@wmertens wmertens reopened this
@wmertens
Collaborator

iPhone button booboo

@my8bird

I will torch the redis thing, it must just be the sharejs example that requires it. Also, I will look into the PATH extension idea (pretty sweet to know if that works as I can use it on some other projects).

@my8bird

@wmertens Updated to fix the issues you found.

@wmertens
Collaborator

Hmm so when people do npm install it builds everything?

@josephg, what are your thoughts on this? All the necessary dependencies are already there, and then the lib dir doesn't have to be part of the git repo any more, making for cleaner diffs.

@CrypticSwarm

Ideally just uses the prepublish, and not postinstall. Coffee should be moved as a dev dep only. It shouldn't be needed to run the server.

@CrypticSwarm

Ideally just uses the prepublish, and not postinstall. Coffee should be moved as a dev dep only. It shouldn't be needed to run the server.

@josephg
Owner

@wmertens the lib directory already isn't part of git. The package's root in npm is index.js, which looks like this:

require('coffee-script');
module.exports = require('./src');

This means cake build isn't needed at all, and coffeescript is needed when you run the server.

The lib directory is only used for two purposes:

  • Building the webclient (via cake webclient). The webclient build concatenates a bunch of the client .js files together then uglifies them.
  • Debugging. When there's a crash, the line numbers are from the javascript file, not the .coffee file. So I often end up referring to the .js files in lib/ to figure out what line of coffeescript the crash is referring to.
@wmertens
Collaborator

So should the postinstall "cake build" be removed and the prepublish have "cake webclient"?

@wmertens wmertens merged commit 7adf7ec into from
@wmertens
Collaborator

Thanks!

@wmertens
Collaborator

Yup - it's because of sockjs, it broke as soon as I updated webclient a couple commits later. I have something that no longer breaks the tests but lets them last forever. I'm getting closer :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 5 deletions.
  1. +9 −2 Cakefile
  2. +3 −1 package.json
  3. +6 −2 src/server/model.coffee
View
11 Cakefile
@@ -1,6 +1,12 @@
{exec} = require 'child_process'
-fs = require 'fs'
-path = require 'path'
+fs = require 'fs'
+path = require 'path'
+os = require 'os'
+
+# Gain access through PATH to all binaries added by `npm install`
+npm_bin = path.resolve(path.join('node_modules', '.bin'))
+path_sep = if os.platform() == 'win32' then ";" else ":"
+process.env.PATH = "#{npm_bin}#{path_sep}#{process.env.PATH}"
task 'test', 'Run all tests', ->
# run directly to get all the delicious output
@@ -9,6 +15,7 @@ task 'test', 'Run all tests', ->
throw err if err
task 'build', 'Build the .js files', (options) ->
+ console.log('Compiling Coffee from src to lib')
exec "coffee --compile --bare --output lib/ src/", (err, stdout, stderr) ->
throw err if err
console.log stdout + stderr
View
4 package.json
@@ -27,7 +27,9 @@
"engine": "node >= 0.4.4",
"scripts": {
"build": "cake build",
- "test": "nodeunit tests.coffee"
+ "test": "nodeunit tests.coffee",
+ "postinstall": "cake build",
+ "prepublish": "cake build"
},
"licenses": [{
"type": "BSD",
View
8 src/server/model.coffee
@@ -20,8 +20,12 @@ isArray = (o) -> Object.prototype.toString.call(o) == '[object Array]'
# - It calls out to the OT functions when necessary
#
# The model is an event emitter. It emits the following events:
-#
-# create(docName, data): A document has been created with the specified name & data
+# - create(docName, data): A document has been created with the specified name & data
+# - add(docName, data)
+# - load(docName, data)
+# - applyOp(docName, opData, snapshot, oldSnapshot)
+# - applyMetaOp(docName, path, value)
+
module.exports = Model = (db, options) ->
# db can be null if the user doesn't want persistance.
Something went wrong with that request. Please try again.