-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[{package.json,*.yml}] | ||
indent_style = space | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.nyc_output |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Vadim Demedes <vdemedes@gmail.com> (https://github.com/vdemedes) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# cssor | ||
|
||
<h1 align="center"> | ||
<br> | ||
<img width="300" src="https://cdn.rawgit.com/vdemedes/cssor/master/media/logo.svg" alt="OhCrash"> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
<br> | ||
<br> | ||
<br> | ||
</h1> | ||
|
||
Browserify for CSS. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
|
||
## Installation | ||
|
||
``` | ||
$ npm install --global cssor | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
``` | ||
$ cssor --help | ||
Usage | ||
This comment has been minimized.
Sorry, something went wrong. |
||
$ cssor [options] [file] | ||
Options | ||
--transform, -t Use a transformer for source files | ||
--output, -o Write output to file | ||
--basedir, -b Set base dir for input file | ||
Examples | ||
$ cat app.css | cssor -t myth -o dist/app.css | ||
$ cssor -i app.css -t myth > dist/app.css | ||
``` | ||
|
||
|
||
## Options | ||
|
||
### transform | ||
|
||
Add a transformer ([rework](https://github.com/reworkcss/rework) plugin). | ||
Can be set multiple times. | ||
|
||
``` | ||
$ cssor -t rework-npm -t myth | ||
``` | ||
|
||
### output | ||
|
||
Write output to the file, instead of stdout. | ||
|
||
``` | ||
$ cssor -o dist/app.css | ||
``` | ||
|
||
### basedir | ||
|
||
Change base directory for @import in stylesheets. | ||
|
||
``` | ||
$ cssor -b styles | ||
``` | ||
|
||
|
||
## License | ||
|
||
MIT © [Vadim Demedes](https://github.com/vdemedes) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
/** | ||
* Dependencies | ||
*/ | ||
|
||
var resolveFrom = require('resolve-from'); | ||
var getStdin = require('get-stdin'); | ||
var arrify = require('arrify'); | ||
var rework = require('rework'); | ||
var meow = require('meow'); | ||
var fs = require('mz/fs'); | ||
|
||
|
||
/** | ||
* CLI | ||
*/ | ||
|
||
var cli = meow([ | ||
'Usage', | ||
' $ cssor [options] [file]', | ||
'', | ||
'Options', | ||
' --transform, -t Use a transformer for source files', | ||
' --output, -o Write output to file', | ||
' --basedir, -b Set base dir for input file', | ||
'', | ||
'Examples', | ||
' $ cat app.css | cssor -t myth -o dist/app.css', | ||
' $ cssor -i app.css -t myth > dist/app.css' | ||
].join('\n'), { | ||
alias: { | ||
t: 'transform', | ||
b: 'basedir', | ||
i: 'input', | ||
o: 'output' | ||
} | ||
}); | ||
|
||
var filename; | ||
var input; | ||
|
||
if (cli.input.length > 0) { | ||
filename = cli.input[0]; | ||
input = fs.readFile(filename, 'utf8'); | ||
} else { | ||
filename = 'app.css'; | ||
input = getStdin(); | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
sindresorhus
|
||
|
||
input.then(function (source) { | ||
var processor = rework(source, { source: filename }); | ||
var transformers = arrify(cli.flags.transform); | ||
|
||
transformers.forEach(function (name) { | ||
var path = resolveFrom(process.cwd(), name); | ||
This comment has been minimized.
Sorry, something went wrong.
sindresorhus
|
||
|
||
processor.use(require(path)()); | ||
}); | ||
|
||
if (cli.flags.basedir) { | ||
process.chdir(cli.flags.basedir); | ||
} | ||
|
||
var output = processor.toString(); | ||
|
||
if (cli.flags.output) { | ||
fs.writeFile(cli.flags.output, output, 'utf8'); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} else { | ||
process.stdout.write(output); | ||
} | ||
}).catch(function (err) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
console.error(err.stack); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "cssor", | ||
"version": "1.0.0", | ||
"description": "Browserify for CSS", | ||
"license": "MIT", | ||
"main": "index.js", | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
"repository": "vdemedes/cssor", | ||
"author": { | ||
"name": "Vadim Demedes", | ||
"email": "vdemedes@gmail.com", | ||
"url": "https://github.com/vdemedes" | ||
}, | ||
"scripts": { | ||
"test": "xo" | ||
This comment has been minimized.
Sorry, something went wrong.
sindresorhus
|
||
}, | ||
"bin": { | ||
"cssor": "cli.js" | ||
}, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
"files": [ | ||
"cli.js" | ||
], | ||
"xo": { | ||
"extends": "vdemedes", | ||
"env": "node" | ||
}, | ||
"devDependencies": { | ||
"eslint-config-vdemedes": "^1.0.1", | ||
"xo": "^0.12.1" | ||
}, | ||
"dependencies": { | ||
"arrify": "^1.0.1", | ||
"get-stdin": "^5.0.1", | ||
"meow": "^3.7.0", | ||
"mz": "^2.1.0", | ||
"resolve-from": "^2.0.0", | ||
"rework": "^1.0.1" | ||
} | ||
} |
1 comment
on commit 466ef73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sindresorhus Thank you for the tips!
Nice logo!
Oh, and check the
alt
attribute ;)