Skip to content

Commit

Permalink
Drop support for legacy environments and package managers
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbynens committed Dec 4, 2017
1 parent 5566334 commit b21826c
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 188 deletions.
20 changes: 3 additions & 17 deletions .travis.yml
Expand Up @@ -3,23 +3,9 @@ node_js:
- "0.10"
- "0.12"
- "4"
- "5"
- "6"
before_script:
- "npm install -g grunt-cli"
# Narwhal uses a hardcoded path to openjdk v6, so use that version
- "sudo apt-get update -qq"
- "sudo apt-get install -qq openjdk-6-jre"
- "PACKAGE=rhino1_7R5; wget https://github.com/mozilla/rhino/releases/download/Rhino1_7R5_RELEASE/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip"
- "PACKAGE=rhino1_7R5; echo -e '#!/bin/sh\\njava -jar /opt/'$PACKAGE'/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino"
- "PACKAGE=ringojs-0.11; wget https://github.com/ringo/ringojs/releases/download/v0.11.0/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip"
- "PACKAGE=ringojs-0.11; sudo ln -s /opt/$PACKAGE/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo"
- "PACKAGE=v0.3.2; wget https://github.com/280north/narwhal/archive/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip"
- "PACKAGE=narwhal-0.3.2; sudo ln -s /opt/$PACKAGE/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal"
# If the enviroment stores rt.jar in a different directory, find it and symlink the directory
- "PREFIX=/usr/lib/jvm; if [ ! -d $PREFIX/java-6-openjdk ]; then for d in $PREFIX/java-6-openjdk-*; do if [ -e $d/jre/lib/rt.jar ]; then sudo ln -s $d $PREFIX/java-6-openjdk; break; fi; done; fi"
- "sudo apt-get install -qq python; python --version"
- "8"
script:
- "grunt ci"
- npm run ci
after_script:
- "grunt shell:cover-coveralls"
- npm run cover-coveralls
31 changes: 1 addition & 30 deletions Gruntfile.js
Expand Up @@ -7,36 +7,11 @@ module.exports = function(grunt) {
'stderr': true,
'failOnError': true
},
'generate-test-data': { // Only when needed
'command': 'if [ ! -f data.json ]; then python generate-test-data.py; fi',
'options': {
'execOptions': {
'cwd': 'tests'
}
}
},
'cover-html': {
'command': 'istanbul cover --report "html" --verbose --dir "coverage" "tests/tests.js"; istanbul report --root "coverage" --format "html"'
},
'cover-coveralls': {
'command': 'istanbul cover --verbose --dir "coverage" "tests/tests.js" && coveralls < coverage/lcov.info|coveralls < coverage/lcov.info; rm -rf coverage/lcov*'
},
'test-narwhal': {
'command': 'echo "Testing in Narwhal..."; export NARWHAL_OPTIMIZATION=-1; narwhal "tests/tests.js"'
},
'test-phantomjs': {
'command': 'echo "Testing in PhantomJS..."; phantomjs "tests/tests.js"'
},
'test-rhino': {
'command': 'echo "Testing in Rhino..."; rhino -opt -1 "tests.js"',
'options': {
'execOptions': {
'cwd': 'tests'
}
}
},
'test-ringo': {
'command': 'echo "Testing in Ringo..."; ringo -o -1 "tests/tests.js"'
'command': 'istanbul cover --verbose --dir "coverage" "tests/tests.js" && coveralls < coverage/lcov.info; rm -rf coverage/lcov*'
},
'test-node': {
'command': 'echo "Testing in Node..."; node "tests/tests.js"'
Expand All @@ -55,10 +30,6 @@ module.exports = function(grunt) {
grunt.registerTask('cover', 'shell:cover-html');
grunt.registerTask('ci', [
'shell:generate-test-data',
'shell:test-narwhal',
'shell:test-phantomjs',
'shell:test-rhino',
'shell:test-ringo',
'shell:test-node',
]);
grunt.registerTask('test', [
Expand Down
38 changes: 2 additions & 36 deletions README.md
Expand Up @@ -12,50 +12,16 @@ Via [npm](https://www.npmjs.com/):
npm install utf8
```

Via [Bower](http://bower.io/):

```bash
bower install utf8
```

Via [Component](https://github.com/component/component):

```bash
component install mathiasbynens/utf8.js
```

In a browser:

```html
<script src="utf8.js"></script>
```

In [Narwhal](http://narwhaljs.org/), [Node.js](https://nodejs.org/), and [RingoJS ≥ v0.8.0](http://ringojs.org/):

```js
var utf8 = require('utf8');
```

In [Rhino](http://www.mozilla.org/rhino/):

```js
load('utf8.js');
```

Using an AMD loader like [RequireJS](http://requirejs.org/):
In [Node.js](https://nodejs.org/):

```js
require(
{
'paths': {
'utf8': 'path/to/utf8'
}
},
['utf8'],
function(utf8) {
console.log(utf8);
}
);
const utf8 = require('utf8');
```

## API
Expand Down
14 changes: 0 additions & 14 deletions bower.json

This file was deleted.

16 changes: 0 additions & 16 deletions component.json

This file was deleted.

15 changes: 9 additions & 6 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "utf8",
"version": "2.1.2",
"version": "3.0.0",
"description": "A well-tested UTF-8 encoder/decoder written in JavaScript.",
"homepage": "https://mths.be/utf8js",
"main": "utf8.js",
Expand All @@ -25,15 +25,18 @@
"utf8.js"
],
"scripts": {
"test": "node tests/tests.js"
"test": "node tests/tests.js",
"test-extended": "node tests/tests.js --extended",
"test-browser": "open tests/index.html",
"ci": "npm run build && npm test",
"build": "cd tests; if [ ! -f data.json ]; then python generate-test-data.py; fi",
"cover-html": "istanbul cover --report html --verbose --dir coverage tests/tests.js; istanbul report --root coverage --format html",
"cover-coveralls": "istanbul cover --verbose --dir coverage tests/tests.js && coveralls < coverage/lcov.info; rm -rf coverage/lcov*"
},
"devDependencies": {
"coveralls": "^2.11.14",
"grunt": "^1.0.1",
"grunt-shell": "^1.1.2",
"istanbul": "^0.4.5",
"qunit-extras": "^1.4.2",
"qunitjs": "~1.11.0",
"requirejs": "^2.3.2"
"qunitjs": "~1.11.0"
}
}
23 changes: 1 addition & 22 deletions tests/index.html
Expand Up @@ -9,27 +9,6 @@
<div id="qunit"></div>
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
<script src="../utf8.js"></script>
<script>
// populate `QUnit.urlParams`
QUnit.urlParams.norequire = /[?&]norequire=true(?:&|$)/.test(location.search);

// load tests.js if not using require.js
document.write(QUnit.urlParams.norequire
? '<script src="tests.js"><\/script>'
: '<script src="../node_modules/requirejs/require.js"><\/script>'
);
</script>
<script>
window.require && require({
'baseUrl': '../node_modules/requirejs/',
'urlArgs': 't=' + (+new Date),
'paths': {
'utf8': '../../utf8'
}
},
['utf8'], function(utf8) {
require(['tests.js']);
});
</script>
<script src="tests.js"></script>
</body>
</html>
52 changes: 5 additions & 47 deletions utf8.js
@@ -1,22 +1,6 @@
/*! https://mths.be/utf8js v2.1.2 by @mathias */
/*! https://mths.be/utf8js v3.0.0 by @mathias */
;(function(root) {

// Detect free variables `exports`
var freeExports = typeof exports == 'object' && exports;

// Detect free variable `module`
var freeModule = typeof module == 'object' && module &&
module.exports == freeExports && module;

// Detect free variable `global`, from Node.js or Browserified code,
// and use it as `root`
var freeGlobal = typeof global == 'object' && global;
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
root = freeGlobal;
}

/*--------------------------------------------------------------------------*/

var stringFromCharCode = String.fromCharCode;

// Taken from https://mths.be/punycode
Expand Down Expand Up @@ -211,34 +195,8 @@

/*--------------------------------------------------------------------------*/

var utf8 = {
'version': '2.1.2',
'encode': utf8encode,
'decode': utf8decode
};

// Some AMD build optimizers, like r.js, check for specific condition patterns
// like the following:
if (
typeof define == 'function' &&
typeof define.amd == 'object' &&
define.amd
) {
define(function() {
return utf8;
});
} else if (freeExports && !freeExports.nodeType) {
if (freeModule) { // in Node.js or RingoJS v0.8.0+
freeModule.exports = utf8;
} else { // in Narwhal or RingoJS v0.7.0-
var object = {};
var hasOwnProperty = object.hasOwnProperty;
for (var key in utf8) {
hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
}
}
} else { // in Rhino or a web browser
root.utf8 = utf8;
}
root.version = '3.0.0';
root.encode = utf8encode;
root.decode = utf8decode;

}(this));
}(typeof exports === 'undefined' ? this.utf8 = {} : exports));

0 comments on commit b21826c

Please sign in to comment.