Skip to content
This repository has been archived by the owner on Aug 19, 2019. It is now read-only.

Commit

Permalink
🐣
Browse files Browse the repository at this point in the history
  • Loading branch information
deepsweet committed Mar 6, 2016
0 parents commit fb32f3a
Show file tree
Hide file tree
Showing 12 changed files with 288 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# https://www.appveyor.com/docs/appveyor-yml

version: "{build}"

init:
- git config --global core.autocrlf false

shallow_clone: true

clone_depth: 1

environment:
matrix:
- nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "5"

cache:
- "%APPDATA%\\npm-cache"

branches:
only:
- master

skip_tags: true

matrix:
fast_finish: true

build: off

install:
- ps: Install-Product node $env:nodejs_version
- npm install -g npm
- npm install

test_script:
- node --version
- npm --version
- npm start ci
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": [ "es2015", "stage-2" ],
"plugins": [ "transform-runtime", "add-module-exports" ]
}
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# http://editorconfig.org/
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 4

[*.{json,yml}]
indent_size = 2

[{.babelrc,.eslintrc}]
indent_size = 2
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"rebem/configs/common",
"rebem/configs/babel"
]
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
build/
coverage/
tmp/
*.sublime-*
*.log
.DS_Store
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# https://docs.travis-ci.com/user/customizing-the-build/

sudo: false

git:
depth: 1

language: node_js

node_js:
- "0.12"
- "4"
- "5"

branches:
only:
- master

matrix:
fast_finish: true

before_install:
- npm install -g npm
- npm --version

script: npm start ci
43 changes: 43 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export default (plugins = [], userOptions) => (input) => {
return function postcss(log) {
const Postcss = require('postcss');

return Promise.all(
input.map(file => {
const options = {
...userOptions,
from: file.path,
to: file.path
};

if (options.map) {
options.map = {
inline: false,
...options.map
};
}

if (file.map !== null) {
options.map = {
...options.map,
prev: file.map
};
}

return Postcss(plugins).process(file.data, options).then(result => {
log(file.path);

result.warnings().forEach(msg => {
log(msg.toString());
});

return {
path: file.path,
data: result.css,
map: result.map || null
};
});
})
);
};
};
21 changes: 21 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The MIT License (MIT)

Copyright (c) 2016–present Kir Belevich

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.
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "start-postcss",
"version": "0.1.0",
"description": "PostCSS task for Start",
"keywords": [ "start", "start-task", "postcss" ],
"homepage": "https://github.com/start-runner/postcss",
"repository": "start-runner/postcss",
"author": "Kir Belevich <kir@soulshine.in> (https://github.com/deepsweet)",
"files": [ "build/" ],
"main": "build/index.js",
"dependencies": {
"postcss": "5.x.x",
"babel-runtime": "6.x.x"
},
"devDependencies": {
"start-babel-cli": "1.x.x",
"start-start-preset": "1.x.x",

"babel-preset-es2015": "6.6.x",
"babel-preset-stage-2": "6.5.x",
"babel-plugin-transform-runtime": "6.6.x",
"babel-plugin-add-module-exports": "0.1.x",

"babel-eslint": "5.0.x",
"eslint-plugin-babel": "3.1.x",
"eslint-config-rebem": "0.3.x",

"tape": "4.5.x",
"husky": "0.11.x"
},
"scripts": {
"start": "start-runner start-start-preset",
"prepush": "npm start prepush",
"prepublish": "npm start build"
},
"engines": {
"node": ">=0.12.0",
"npm": ">=2.7.0"
},
"license": "MIT"
}
54 changes: 54 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# start-postcss

[![npm](https://img.shields.io/npm/v/start-postcss.svg?style=flat-square)](https://www.npmjs.com/package/start-postcss)
[![linux build](https://img.shields.io/travis/start-runner/postcss.svg?label=linux&style=flat-square)](https://travis-ci.org/start-runner/postcss)
[![windows build](https://img.shields.io/appveyor/ci/start-runner/postcss.svg?label=windows&style=flat-square)](https://ci.appveyor.com/project/start-runner/postcss)
[![coverage](https://img.shields.io/codecov/c/github/start-runner/postcss.svg?style=flat-square)](https://codecov.io/github/start-runner/postcss)
[![deps](https://img.shields.io/gemnasium/start-runner/postcss.svg?style=flat-square)](https://gemnasium.com/start-runner/postcss)
[![gitter](https://img.shields.io/badge/gitter-join_chat_%E2%86%92-46bc99.svg?style=flat-square)](https://gitter.im/start-runner/start)

[PostCSS](http://postcss.org/) task for [Start](https://github.com/start-runner/start).

## Install

```
npm i -S start-postcss
```

## Usage

```js
import start from 'start';
import reporter from 'start-pretty-reporter';
import files from 'start-files';
import clean from 'start-clean';
import read from 'start-read';
import less from 'start-less';
import postcss from 'start-postcss';
import rename from 'start-rename';
import write from 'start-write';

import autoprefixer from 'autoprefixer';

export function build() {
return start(reporter())(
files('build/'),
clean(),
files('lib/**/*.less'),
read(),
less({ sourceMap: true }),
postcss([ autoprefixer ], { map: true }),
rename(file => file.replace(/\.less$/, '.css')),
write('build/')
);
}
```

This task relies on `[{ path, data, map }]` input and provides the same, see [documentation](https://github.com/start-runner/start#readme) for details.

## Arguments

`postcss(plugins, options)`

* `plugins`[PostCSS plugins](https://github.com/postcss/postcss#plugins), `[]` by default
* `options`[PostCSS options](https://github.com/postcss/postcss#options)
5 changes: 5 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"rebem/configs/test"
]
}
25 changes: 25 additions & 0 deletions test/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import test from 'tape';

import task from '../../lib/';

test('basic', t => {
t.equal(
typeof task,
'function',
'1st function'
);

t.equal(
typeof task(),
'function',
'2nd function'
);

t.equal(
typeof task()(),
'function',
'3rd function'
);

t.end();
});

0 comments on commit fb32f3a

Please sign in to comment.