-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,34 @@ | ||
component-livescript | ||
==================== | ||
|
||
Component(1) plugin to compile LiveScript | ||
Component(1) plugin to compile LiveScript files on-the-fly. This allows you to write components in LiveScript. | ||
Based on [anthonyshort/component-coffee](https://github.com/anthonyshort/component-coffee). | ||
|
||
|
||
## Installation | ||
|
||
```bash | ||
npm install component-livescript | ||
``` | ||
|
||
## Usage | ||
|
||
```bash | ||
component build --use component-livescript | ||
``` | ||
|
||
Add you LiveScript files to the `scripts` section of your `component.json` | ||
|
||
```json | ||
{ | ||
"name": "foo", | ||
"scripts": ["index.ls", "foo.ls", "bar.ls"] | ||
} | ||
``` | ||
|
||
Now in your `index.ls` file you can require or [require!](http://livescript.net/#operators) it: | ||
|
||
```livescript | ||
foo = require 'foo' | ||
require! bar | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var livescript = require('livescript'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
|
||
module.exports = function (builder) { | ||
builder.hook('before scripts', function (pkg, next) { | ||
if (pkg.config.scripts === undefined) { | ||
return next(); | ||
} | ||
|
||
var ls = pkg.config.scripts.filter(function(file) { | ||
return path.extname(file) === '.ls'; | ||
}); | ||
|
||
if (ls.length === 0) { | ||
return next(); | ||
} | ||
|
||
ls.forEach(function (file) { | ||
var realpath = pkg.path(file); | ||
var str = fs.readFileSync(realpath, 'utf8'); | ||
var compiled = livescript.compile(str, { filename: realpath, bare: true }); | ||
var filename = file.replace('.ls', '.js'); | ||
|
||
pkg.addFile('scripts', filename, compiled); | ||
pkg.removeFile('scripts', file); | ||
}); | ||
|
||
next(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "component-livescript", | ||
"version": "0.1.0", | ||
"description": "LiveScript plugin for Component(1)", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wryk/component-livescript.git" | ||
}, | ||
"keywords": [ | ||
"component", | ||
"livescript", | ||
"plugin" | ||
], | ||
"author": "Mathieu Gallé-Tessonneau", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/wryk/component-livescript/issues" | ||
}, | ||
"dependencies": { | ||
"LiveScript": "~1.2.0" | ||
}, | ||
"peerDependencies": { | ||
"component": ">= 0.14" | ||
} | ||
} |