Skip to content

Commit

Permalink
sync with RSVP.
Browse files Browse the repository at this point in the history
- performance
- reduced file-size
- bugfixes
- new build system

[fixes #38, #34, #33, #28, #26, #18, #14, #9, #5]
  • Loading branch information
stefanpenner committed Aug 27, 2014
1 parent d7ec36b commit b301f17
Show file tree
Hide file tree
Showing 60 changed files with 2,464 additions and 6,422 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/main.js
/tmp
/dist
/docs
2 changes: 2 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"expect"
],

"esnext": true,
"proto": true,
"node" : true,
"browser" : true,

Expand Down
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/node_modules/
/tmp
/lib
/tasks
/test
/vendor
Expand Down
17 changes: 17 additions & 0 deletions .release.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"non-interactive": true,
"dry-run": false,
"verbose": false,
"force": false,
"pkgFiles": ["package.json", "bower.json"],
"increment": "patch",
"commitMessage": "Release %s",
"tagName": "%s",
"tagAnnotation": "Release %s",
"buildCommand": "npm run-script build-all",
"distRepo": "git@github.com:components/rsvp.js.git",
"distStageDir": "tmp/stage",
"distBase": "dist",
"distFiles": ["**/*", "../package.json", "../bower.json"],
"publish": false
}
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
language: node_js
node_js:
- '0.10'
before_install:
- npm install -g grunt-cli
after_success: grunt build s3:dev
after_success:
- "./bin/publish_to_s3.js"
env:
global:
- secure: |-
Expand All @@ -15,3 +14,4 @@ env:
mrNGoG5AycW+d5jlghF9PJHQW1ETT9jWI7bGe9QX1QRpoSLkGAvxavrujmhu
UNRP/pe5AJBh3zDED38nD/ZGtrcSYQ5CC6QbFLx5mLtqn7mNTo1m3C5lr+55
Sb6mnyLLz2eoPBUMcXwY1i9Qisy40uhfV9VuD5B/gvVud2+oJWI=
- EMBER_ENV=production
74 changes: 74 additions & 0 deletions Brocfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* jshint node:true, undef:true, unused:true */
var AMDFormatter = require('es6-module-transpiler-amd-formatter');
var closureCompiler = require('broccoli-closure-compiler');
var compileModules = require('broccoli-compile-modules');
var mergeTrees = require('broccoli-merge-trees');
var moveFile = require('broccoli-file-mover');
var es3Recast = require('broccoli-es3-safe-recast');
var concat = require('broccoli-concat');
var replace = require('broccoli-string-replace');
var calculateVersion = require('./lib/calculateVersion');
var path = require('path');
var trees = [];
var env = process.env.EMBER_ENV || 'development';

var bundle = compileModules('lib', {
inputFiles: ['es6-promise.umd.js'],
output: '/es6-promise.js',
formatter: 'bundle',
});

trees.push(bundle);
trees.push(compileModules('lib', {
inputFiles: ['**/*.js'],
output: '/amd/',
formatter: new AMDFormatter()
}));

if (env === 'production') {
trees.push(closureCompiler(moveFile(bundle, {
srcFile: 'es6-promise.js',
destFile: 'es6-promise.min.js'
}), {
compilation_level: 'ADVANCED_OPTIMIZATIONS',
}));
}

var distTree = mergeTrees(trees.concat('config'));
var distTrees = [];

distTrees.push(concat(distTree, {
inputFiles: [
'versionTemplate.txt',
'es6-promise.js'
],
outputFile: '/es6-promise.js'
}));

if (env === 'production') {
distTrees.push(concat(distTree, {
inputFiles: [
'versionTemplate.txt',
'es6-promise.min.js'
],
outputFile: '/es6-promise.min.js'
}));
}

if (env !== 'development') {
distTrees = distTrees.map(es3Recast);
}

distTree = mergeTrees(distTrees);
var distTree = replace(distTree, {
files: [
'es6-promise.js',
'es6-promise.min.js'
],
pattern: {
match: /VERSION_PLACEHOLDER_STRING/g,
replacement: calculateVersion()
}
});

module.exports = distTree;
44 changes: 5 additions & 39 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,9 @@
# master
# Master

# 2.0.4

* Fix npm package

# 2.0.3

* Fix useSetTimeout bug

# 2.0.2

* Adding RSVP#rethrow
* add pre-built AMD link to README
* adding promise#fail
# 2.0.0

# 2.0.1
* misc IE fixes, including IE array detection
* upload passing builds to s3
* async: use three args for addEventListener
* satisfy both 1.0 and 1.1 specs
* Run reduce tests only in node
* RSVP.resolve now simply uses the internal resolution procedure
* prevent multiple promise resolutions
* simplify thenable handling
* pre-allocate the deferred's shape
* Moved from Rake-based builds to Grunt
* Fix Promise subclassing bug
* Add RSVP.configure('onerror')
* Throw exception when RSVP.all is called without an array
* refactor RSVP.all to just use a promise directly
* Make `RSVP.denodeify` pass along `thisArg`
* add RSVP.reject
* Reject promise if resolver function throws an exception
* add travis build-status
* correctly test and fix self fulfillment
* remove promise coercion.
* Fix infinite recursion with deep self fulfilling promises
* doc fixes
* re-sync with RSVP. Many large performance improvements and bugfixes.

# 2.0.0
# 1.0.0

* No changelog beyond this point. Here be dragons.
* first subset of RSVP
53 changes: 0 additions & 53 deletions Gruntfile.js

This file was deleted.

12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ To use:
var Promise = require('es6-promise').Promise;
```

## Usage in IE<10
## Usage in IE<9

`catch` is a reserved word in IE<10, meaning `promise.catch(func)` throws a syntax error. To work around this, use a string to access the property:
`catch` is a reserved word in IE<9, meaning `promise.catch(func)` throws a syntax error. To work around this, use a string to access the property:

```js
promise['catch'](function(err) {
Expand All @@ -43,10 +43,4 @@ promise.then(undefined, function(err) {

## Building & Testing

This package uses the [grunt-microlib](https://github.com/thomasboyt/grunt-microlib) package for building.

Custom tasks:

* `grunt test` - Run Mocha tests through Node and PhantomJS.
* `grunt test:phantom` - Run Mocha tests through PhantomJS (browser build).
* `grunt test:node` - Run Mocha tests through Node (CommonJS build).
* `npm run build-all && npm test` - Run Mocha tests through Node and PhantomJS.
28 changes: 28 additions & 0 deletions bin/publish_to_s3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env node

// To invoke this from the commandline you need the following to env vars to exist:
//
// S3_BUCKET_NAME
// TRAVIS_BRANCH
// TRAVIS_TAG
// TRAVIS_COMMIT
// S3_SECRET_ACCESS_KEY
// S3_ACCESS_KEY_ID
//
// Once you have those you execute with the following:
//
// ```sh
// ./bin/publish_to_s3.js
// ```
var S3Publisher = require('ember-publisher');
var configPath = require('path').join(__dirname, '../config/s3ProjectConfig.js');
publisher = new S3Publisher({ projectConfigPath: configPath });

// Always use wildcard section of project config.
// This is useful when the including library does not
// require channels (like in ember.js / ember-data).
publisher.currentBranch = function() {
return (process.env.TRAVIS_BRANCH === 'master') ? 'wildcard' : 'no-op';
};
publisher.publish();

29 changes: 29 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "es6-promise",
"namespace": "Promise",
"version": "2.0.0",
"description": "A polyfill for ES6-style Promises, tracking rsvp",
"authors": [
"Stefan Penner <stefan.penner@gmail.com>"
],
"main": "dist/es6-promise.js",
"keywords": [
"promise"
],
"repository": {
"type": "git",
"url": "git://github.com/jakearchibald/ES6-Promises.git"
},
"bugs": {
"url": "https://github.com/jakearchibald/ES6-Promises/issues"
}
"license": "MIT",
"ignore": [
"node_modules",
"bower_components",
"test",
"tests",
"vendor",
"tasks"
]
}
26 changes: 26 additions & 0 deletions config/s3ProjectConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Using wildcard because es6-promise does not currently have a
* channel system in place.
*/
module.exports = function(revision,tag,date){
return {
'es6-promise.js':
{ contentType: 'text/javascript',
destinations: {
wildcard: [
'es6-promise-latest.js',
'es6-promise-' + revision + '.js'
]
}
},
'es6-promise.min.js':
{ contentType: 'text/javascript',
destinations: {
wildcard: [
'es6-promise-latest.min.js',
'es6-promise-' + revision + '.min.js'
]
}
}
}
}
7 changes: 7 additions & 0 deletions config/versionTemplate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
* @version VERSION_PLACEHOLDER_STRING
*/
36 changes: 36 additions & 0 deletions lib/calculateVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var fs = require('fs');
var path = require('path');

module.exports = function () {
var packageVersion = require('../package.json').version;
var output = [packageVersion];
var gitPath = path.join(__dirname,'..','.git');
var headFilePath = path.join(gitPath, 'HEAD');

if (packageVersion.indexOf('+') > -1) {
try {
if (fs.existsSync(headFilePath)) {
var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'});
var branchName = headFile.split('/').slice(-1)[0].trim();
var refPath = headFile.split(' ')[1];
var branchSHA;

if (refPath) {
var branchPath = path.join(gitPath, refPath.trim());
branchSHA = fs.readFileSync(branchPath);
} else {
branchSHA = branchName;
}

output.push(branchSHA.slice(0,10));
}
} catch (err) {
console.error(err.stack);
}
return output.join('.');
} else {
return packageVersion;
}
};
Loading

0 comments on commit b301f17

Please sign in to comment.