Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
updated: fixed conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Apr 13, 2019
1 parent 82173f4 commit ce3327b
Show file tree
Hide file tree
Showing 10 changed files with 2,139 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .eslintrc
@@ -0,0 +1,7 @@
extends: eslint-config-riot
env:
mocha: true

parserOptions:
ecmaVersion: 2018
sourceType: 'module'
40 changes: 40 additions & 0 deletions .gitignore
@@ -0,0 +1,40 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# mac useless file
.DS_Store
15 changes: 15 additions & 0 deletions .travis.yml
@@ -0,0 +1,15 @@
language: node_js
node_js:
- "8.*"

branches:
only:
- master

before_script:
- npm run build

notifications:
email: false

sudo: false
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Gianluca Guarini

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.
26 changes: 24 additions & 2 deletions README.md
@@ -1,2 +1,24 @@
# now
Riot.js now builder
# @riotjs/now
Riot.js [now](https://zeit.co/docs/v2/deployments/builders/overview/) builder

[![Build Status][travis-image]][travis-url]

[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-url]
[![MIT License][license-image]][license-url]


## Usage


[travis-image]:https://img.shields.io/travis/riot/now.svg?style=flat-square
[travis-url]:https://travis-ci.org/riot/now

[license-image]:http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
[license-url]:LICENSE

[npm-version-image]:http://img.shields.io/npm/v/@riotjs/now.svg?style=flat-square
[npm-downloads-image]:http://img.shields.io/npm/dm/@riotjs/now.svg?style=flat-square
[npm-url]:https://npmjs.org/package/@riotjs/now

## API
2 changes: 2 additions & 0 deletions index.js
@@ -0,0 +1,2 @@
require = require('esm')(module) // eslint-disable-line
module.exports = require('./index.next.js')
28 changes: 28 additions & 0 deletions index.next.js
@@ -0,0 +1,28 @@
import { FileBlob } from '@now/build-utils'
import { compile } from '@riotjs/compiler'

// generate the build fingerprint
export const analyze = ({ files, entrypoint }) => files[entrypoint].digest

/**
* Build the riot files using the file streap API
* @param {Files} options.files - https://zeit.co/docs/v2/deployments/builders/developer-guide/#files
* @param {string} options.entrypoint - https://zeit.co/docs/v2/deployments/builders/developer-guide/#builder-options
* @param {Object} options.config - user options
* @returns {Files} transformed files output
*/
export async function build({ files, entrypoint, config }) {
const stream = files[entrypoint].toStream()
const options = {
file: entrypoint,
...config
}
const { data } = await FileBlob.fromStream({ stream })
const content = data.toString()
const output = compile(content, options)
const result = new FileBlob({ data: output })

return {
[entrypoint]: result
}
}

0 comments on commit ce3327b

Please sign in to comment.