Skip to content

Commit

Permalink
[#2] Compile package to ES5 for NPM
Browse files Browse the repository at this point in the history
The ./src folder contains our code (ES6), the ./lib contains it compiled to
ES5, and the schemas cache was moved from ./lib/schemas to ./schemas.

In our tests, I've prefered to test the compiled ES5, instead of our ES6 code.
This means that the stacktraces will point to the compiled ES5 code, but if
they pass, we can be sure that the resulting package works (including the
compilation process).
  • Loading branch information
vitorbaptista committed Feb 2, 2016
1 parent a4d8a0a commit 9300ade
Show file tree
Hide file tree
Showing 24 changed files with 33 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# Compiled ES5 files
lib/
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Source ES6 files
src/

# Coverage directory used by tools like istanbul
coverage/
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Polyfills have been used:
es6-promise

# Usage
## Usage

```javascript
var registry = require('datapackage-registry')('http://schemas.datapackages.org/registry.csv')
Expand All @@ -19,3 +19,15 @@ registry.get('base')
// deal with error
}
```
## Developer notes
These notes are intended to help people that want to contribute to this
package itself. If you just want to use it, you can safely ignore this.
### Updating the local schemas cache
We cache the schemas from <https://github.com/dataprotocols/schemas> using
git-subtree. To update it, use:
git subtree pull --prefix schemas https://github.com/dataprotocols/schemas.git master --squash
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Karma configuration
//
// Generated on Sat Jan 30 2016 19:12:29 GMT+0000 (GMT)

module.exports = function(config) {
Expand Down Expand Up @@ -29,8 +30,8 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'lib/**/*.js': ['browserify'],
'test/**/*.js': ['browserify'],
'lib/**/*.js': ['browserify']
},


Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@
"watchify": "^3.7.0"
},
"scripts": {
"compile": "babel -d lib/ src/",
"prepublish": "npm run compile",
"pretest": "npm run compile",
"test": "npm run lint; npm run test:nodejs; npm run test:browser",
"test:browser": "karma start",
"test:nodejs": "mocha",
"lint": "eslint lib/*.js lib/**/*.js test/*.js test/**/*.js",
"lint": "eslint src/*.js src/**/*.js test/*.js test/**/*.js",
"coverage": "babel-node ./node_modules/.bin/babel-istanbul cover _mocha",
"coveralls": "cat ./coverage/lcov.info | coveralls"
},
Expand Down Expand Up @@ -77,5 +80,9 @@
"type": "git",
"url": "https://github.com/okfn/datapackage-registry-js.git"
},
"license": "MIT"
"license": "MIT",
"directories": {
"lib": "lib",
"schemas": "schemas"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/index.js → src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import isBrowser from './util/is-browser';
import isRemoteURL from './util/is-remote-url';

const DEFAULT_REGISTRY_PATH = (isBrowser) ? 'http://schemas.datapackages.org/registry.csv' :
path.join(__dirname, 'schemas', 'registry.csv');
path.join(__dirname, '..', 'schemas', 'registry.csv');

class Registry {
constructor(pathOrURL = DEFAULT_REGISTRY_PATH) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

1 comment on commit 9300ade

@pwalsh
Copy link
Contributor

@pwalsh pwalsh commented on 9300ade Feb 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎱

Please sign in to comment.