Skip to content

Commit 8048637

Browse files
committed
Merge pull request #227 from wangxiao/master
优化代码,修正 npmignore。
2 parents 5e0a7f3 + fbcbfdc commit 8048637

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

.npmignore

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
*.tgz
2-
node_modules/
3-
package/
4-
tests/
5-
tools/
6-
demo/
7-
src/cloud.js
8-
*.sh
1+
coverage
2+
demo
3+
node_modules
4+
src
5+
test
6+
tools
7+
.babelrc
8+
.gitignore
9+
.travis.yml
10+
bower.json
11+
gulpfile.babel.js
12+
readme.txt

gulpfile.babel.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ gulp.task('babel-node', ['clean-node'], () => {
118118
.pipe(gulp.dest('dist/node/'));
119119
});
120120

121+
// 压缩 node 版本代码
122+
gulp.task('uglify-node', ['babel-node'], () => {
123+
return gulp.src([
124+
'dist/node/**/*.js'
125+
])
126+
.pipe(uglify())
127+
.pipe(gulp.dest('dist/node/'));
128+
});
129+
121130
gulp.task('clean-demo', () => {
122131
return gulp.src(['demo/test-es5.js'])
123132
.pipe(clean());

src/utils.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,30 +98,35 @@ module.exports = function(AV) {
9898
};
9999

100100
/**
101-
* Call this method first to set up your authentication tokens for LC.
102-
* You can get your keys from the Data Browser on http://leancloud.cn .
103-
* @param {Object} incloud appId, appKey, masterKey
104-
*/
101+
* Call this method first to set up your authentication tokens for AV.
102+
* You can get your app keys from the LeanCloud dashboard on http://leancloud.cn .
103+
* @function AV.init
104+
* @param args initialize options.
105+
* @param args.appId application id
106+
* @param args.appKey application key
107+
* @param args.masterKey application master key
108+
*/
105109

106-
AV.init = (...options) => {
107-
switch (options.length) {
110+
AV.init = (...args) => {
111+
switch (args.length) {
108112
case 1:
113+
const options = args[0];
109114
if (typeof options === 'object') {
110115
if (!AV._config.isNode && options.masterKey) {
111116
throw new Error('AV.init(): Master Key is only used in Node.js.');
112117
}
113-
initialize(options[0].appId, options[0].appKey, options[0].masterKey);
118+
initialize(options.appId, options.appKey, options.masterKey);
114119
} else {
115120
throw new Error('AV.init(): Parameter is not correct.');
116121
}
117122
break;
118123
// 兼容旧版本的初始化方法
119124
case 2:
120125
case 3:
121-
if (!AV._config.isNode && options.length === 3) {
126+
if (!AV._config.isNode && args.length === 3) {
122127
throw new Error('AV.init(): Master Key is only used in Node.js.');
123128
}
124-
initialize(...options);
129+
initialize(...args);
125130
break;
126131
}
127132
};
@@ -146,6 +151,7 @@ module.exports = function(AV) {
146151

147152
/**
148153
* Call this method to set production environment variable.
154+
* @function AV.setProduction
149155
* @param {Boolean} production True is production environment,and
150156
* it's true by default.
151157
*/

0 commit comments

Comments
 (0)