Skip to content

Commit

Permalink
add .npmignore and prepublishOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
givanse committed Jan 4, 2019
1 parent 1f36273 commit 8d68181
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
src/index.ts
test
rollup.config.js
karma.conf.js
*.md
yarn.lock
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ with an express/sinatra style syntax for defining routes and their handlers.
Pretender will temporarily replace native XMLHttpRequest and Fetch , intercept
all requests, and direct them to little pretend service you've defined.

**:warning: Pretender only works in the browser!**

```javascript
const PHOTOS = {
"10": {
Expand All @@ -40,6 +38,23 @@ const server = new Pretender(function() {
$.get('/photos/12', {success() => { ... }})
```
## Usage examples
You can load Pretender directly in the browser.
```javascript
<script src="pretender.js"></script>
```
Or as a module.
```javascript
import Pretender from 'pretender';
const server = new Pretender(function() {});
```
Full example: [use-pretender-as-a-module](https://github.com/givanse/use-pretender-as-a-module)
## The Server DSL
The server DSL is inspired by express/sinatra. Pass a function to the Pretender constructor
that will be invoked with the Pretender instance as its context. Available methods are
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function(config) {
'node_modules/es6-promise/dist/es6-promise.auto.js',
'node_modules/abortcontroller-polyfill/dist/abortcontroller-polyfill-only.js',
'node_modules/whatwg-fetch/dist/fetch.umd.js',
'pretender.js',
'dist/pretender.js',
'test/**/*.js'
],

Expand All @@ -35,7 +35,7 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'pretender.js': ['coverage']
'dist/pretender.js': ['coverage']
},

coverageReporter: {
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "pretender",
"version": "2.1.0",
"main": "./pretender.js",
"main": "./dist/pretender.js",
"module": "./src/pretender.es.js",
"description": "Pretender is a mock server library for XMLHttpRequest and Fetch, that comes with an express/sinatra style syntax for defining routes and their handlers.",
"license": "MIT",
"engines": {
"node": "6.* || 8.* || 10.* || >= 11.*"
},
"scripts": {
"build": "rollup --config",
"prepublishOnly": "npm run build && npm run tests-only",
"pretest": "bower install",
"build": "rollup --config",
"test": "npm run lint && npm run jscs && npm run tests-only",
"test-ci": "npm run pretest && npm run lint && npm run jscs && npm run tests-only-ci",
"test-ci": "npm run pretest && npm run build && npm run lint && npm run jscs && npm run tests-only-ci",
"tests-only": "karma start --single-run",
"tests-only-ci": "karma start --single-run --browsers PhantomJS",
"lint": "jshint test",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
output: [
{
name: 'Pretender',
file: 'pretender.js',
file: 'dist/pretender.js',
format: 'iife',
globals: {
[selfId]: 'self',
Expand Down

0 comments on commit 8d68181

Please sign in to comment.