Skip to content

Commit 035d31b

Browse files
committed
initial version
1 parent 9f02cca commit 035d31b

19 files changed

+604
-1
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"stage": 0
3+
}

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
root = true
3+
4+
[*.{js,jsx,json}]
5+
end_of_line = lf
6+
insert_final_newline = true
7+
charset = utf-8
8+
indent_style = space
9+
indent_size = 2

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/dist/*
2+
**/node_modules/*
3+
**/*.min.*

.eslintrc

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
parser: babel-eslint
3+
4+
ecmaFeatures:
5+
arrowFunctions: true
6+
blockBindings: true
7+
classes: true
8+
defaultParams: true
9+
destructuring: true
10+
forOf: true
11+
generators: false
12+
modules: true
13+
objectLiteralComputedProperties: true
14+
objectLiteralDuplicateProperties: false
15+
objectLiteralShorthandMethods: true
16+
objectLiteralShorthandProperties: true
17+
spread: true
18+
superInFunctions: true
19+
templateStrings: true
20+
21+
env:
22+
browser: true
23+
node: true
24+
es6: true
25+
26+
globals:
27+
__resourceQuery: false
28+
bootstrap: false
29+
describe: false
30+
describeSaga: false
31+
describeEvent: false
32+
describeCommand: false
33+
describeScene: false
34+
before: false
35+
it: false
36+
xit: false
37+
window : false
38+
beforeEach : false
39+
afterEach : false
40+
after : false
41+
before : false
42+
beforeEachChapter: false
43+
describeScenario: false
44+
describeChapter: false
45+
describeStep: false
46+
document : false
47+
window: false
48+
File : false
49+
FormData: false
50+
QCodeDecoder: false
51+
$: false
52+
L: false
53+
btoa: false
54+
escape: false
55+
angular: false
56+
jQuery: false
57+
ga: false
58+
59+
settings:
60+
jsx: true
61+
62+
ecmaFeatures:
63+
jsx: true
64+
65+
rules:
66+
67+
# ERRORS
68+
curly: [2, "multi-line"]
69+
70+
# WARNINGS
71+
no-unused-vars: [1, {vars: all, args: none}]
72+
semi-spacing: 1
73+
no-empty: 1
74+
handle-callback-err: 1
75+
eqeqeq: 1
76+
quotes: [1, 'single']
77+
no-unused-expressions: 1
78+
no-throw-literal: 1
79+
semi: 1
80+
block-scoped-var: 1
81+
no-alert: 1
82+
no-console: 1
83+
new-cap: 1
84+
space-unary-ops: 1
85+
86+
# DISABLED
87+
space-after-keywords: 0
88+
dot-notation: 0
89+
consistent-return: 0
90+
brace-style: 0
91+
no-multi-spaces: 0
92+
no-underscore-dangle: 0
93+
key-spacing: 0
94+
comma-spacing: 0
95+
no-shadow: 0
96+
no-mixed-requires: 0
97+
space-infix-ops: 0
98+
strict: 0
99+
camelcase: 0
100+
no-wrap-func: 0
101+
comma-dangle: 0
102+
no-extra-semi: 0
103+
no-use-before-define: [0, "nofunc"]
104+
105+
# AUTOMATED BY EDITORCONFIG
106+
eol-last: 0
107+
no-trailing-spaces: 0
108+
indent: 0

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Ignore specific files
2+
.settings.xml
3+
.monitor
4+
.DS_Store
5+
*.orig
6+
npm-debug.log
7+
npm-debug.log.*
8+
*.dat
9+
10+
# Ignore various temporary files
11+
*~
12+
*.swp
13+
14+
15+
# Ignore various Node.js related directories and files
16+
node_modules
17+
node_modules/**/*
18+
coverage/**/*

.npmignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
test/
2+
lib/
3+
coverage/
4+
.babelrc
5+
.editorconfig
6+
.eslintignore
7+
.eslintrc
8+
.gitignore
9+
bower.json
10+
gulpfile.js
11+
karma.conf.js

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# i18next-browser-languageDetector
2-
language detector used in browser environment for i18next
2+
3+
4+
`gulp build` builds release version
5+
`gulp build --debug` will build unminified version

bin/index.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/index.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bower.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "i18nextBrowserLanguageDetector",
3+
"version": "0.0.1",
4+
"main": "./bin/index.js",
5+
"dependencies": {},
6+
"ignore": [
7+
"test/",
8+
"lib/",
9+
"coverage/",
10+
".babelrc",
11+
".gitignore",
12+
".editorconfig",
13+
".eslintignore",
14+
".eslintrc",
15+
".npmignore",
16+
"gulpfile.js",
17+
"package.json",
18+
"karma.conf.js"
19+
]
20+
}

gulpfile.js

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
var gulp = require('gulp'),
2+
argv = require('yargs').argv,
3+
gulpif = require('gulp-if'),
4+
uglify = require('gulp-uglify'),
5+
sourcemaps = require('gulp-sourcemaps'),
6+
source = require('vinyl-source-stream'),
7+
buffer = require('vinyl-buffer'),
8+
browserify = require('browserify'),
9+
watchify = require('watchify'),
10+
babel = require('babelify'),
11+
eslint = require('gulp-eslint'),
12+
Server = require('karma').Server;
13+
14+
var entry = 'Browser.js',
15+
output = 'index.js';
16+
17+
function compile(watch) {
18+
var bundler = browserify('./lib/' + entry, { debug: argv.debug, standalone: 'i18nextBrowserLanguageDetector' }).transform(babel);
19+
if (watch) {
20+
bundle = watchify(bundler);
21+
}
22+
23+
function rebundle() {
24+
bundler.bundle()
25+
.on('error', function(err) { console.error(err); this.emit('end'); })
26+
.pipe(source(output))
27+
.pipe(buffer())
28+
.pipe(gulpif(!argv.debug, uglify()))
29+
.pipe(sourcemaps.init({ loadMaps: true }))
30+
.pipe(sourcemaps.write('./'))
31+
.pipe(gulp.dest('./bin'));
32+
}
33+
34+
if (watch) {
35+
bundler.on('update', function() {
36+
console.log('-> bundling...');
37+
rebundle();
38+
});
39+
}
40+
41+
rebundle();
42+
}
43+
44+
gulp.task('eslint', function () {
45+
return gulp.src(['src/**/*.js'])
46+
.pipe(eslint({
47+
useEslintrc: true
48+
}))
49+
.pipe(eslint.format())
50+
.pipe(eslint.failAfterError());
51+
});
52+
53+
gulp.task('test', function (done) {
54+
new Server({
55+
configFile: __dirname + '/karma.conf.js',
56+
singleRun: true,
57+
reporters: [ 'spec', 'coverage' ],
58+
}, done).start();
59+
});
60+
61+
gulp.task('test_compat', function (done) {
62+
new Server({
63+
configFile: __dirname + '/karma.backward.conf.js'
64+
}, done).start();
65+
});
66+
67+
68+
gulp.task('tdd', function (done) {
69+
new Server({
70+
configFile: __dirname + '/karma.conf.js'
71+
}, done).start();
72+
});
73+
74+
function watch() {
75+
return compile(true);
76+
};
77+
78+
gulp.task('build', function() { return compile(); });
79+
gulp.task('watch', function() { return watch(); });
80+
81+
gulp.task('default', ['watch']);

karma.conf.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//const istanbul = require( 'browserify-istanbul' );
2+
3+
module.exports = function(karma) {
4+
karma.set({
5+
6+
frameworks: [ 'mocha', 'chai', 'sinon', 'browserify' ],
7+
8+
files: [
9+
//'vendor/external.js',
10+
'test/**/*.spec.js',
11+
//{ pattern: 'test/locales/**/*.json', watched: true, included: false, served: true},
12+
],
13+
14+
// proxies: {
15+
// '/locales': 'http://localhost:9876/base/test/locales'
16+
// },
17+
18+
reporters: [ 'spec'/*, 'coverage' */],
19+
20+
preprocessors: {
21+
'test/**/*.spec.js': [ 'browserify' ],
22+
'lib/**/*.js': [ 'browserify' ]
23+
},
24+
25+
browsers: [ 'PhantomJS' ],
26+
27+
port: 9876,
28+
29+
//logLevel: 'LOG_DEBUG',
30+
31+
//singleRun: true,
32+
//autoWatch: false,
33+
//
34+
// client: {
35+
// mocha: {
36+
// reporter: 'spec', // change Karma's debug.html to the mocha web reporter
37+
// ui: 'tdd'
38+
// }
39+
// },
40+
41+
// browserify configuration
42+
browserify: {
43+
debug: true,
44+
transform: [
45+
'babelify', /*'brfs',*/ 'browserify-istanbul'
46+
]
47+
},
48+
49+
coverageReporter: {
50+
type : 'html', // using fixed version from branch: https://github.com/karma-runner/karma-coverage/issues/157
51+
dir : 'coverage/'
52+
}
53+
});
54+
};

0 commit comments

Comments
 (0)