Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Fix some lint issues and add npm run build for UMD module #36

Merged
merged 4 commits into from Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion Gruntfile.js
Expand Up @@ -28,10 +28,13 @@ module.exports = function(grunt) {
jshint: {

options: {
reporterOutput: '',
browser: true,
eqeqeq: true,
globals: {
AWS: true
}
},
undef: true
},

src: ['src/*.js']
Expand Down Expand Up @@ -71,6 +74,18 @@ module.exports = function(grunt) {
}
},

umd: {
all: {
options: {
src: 'dist/amazon-cognito.min.js',
deps: {
default: [{'aws-sdk': 'AWS'}],
global: [{'AWS': 'AWS'}]
}
}
}
},

watch: {
scripts: {
files: ['src/*.js'],
Expand All @@ -85,6 +100,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-umd');

grunt.registerTask('default', ['qunit']);

Expand Down
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -21,7 +21,9 @@ connectivity.
* http://aws.amazon.com/sdk-for-browser/

2. Download and include the Cognito Sync Manager for JavaScript:
* [/dist/amazon-cognito.min.js](https://github.com/aws/amazon-cognito-js/blob/master/dist/amazon-cognito.min.js)
* `<script src="/path/to/amazon-cognito.min.js"></script>`
* Or... `import 'amazon-cognito-js';`
* Or... `require('amazon-cognito-js');`

## Usage

Expand Down Expand Up @@ -121,7 +123,7 @@ dataset.synchronize({
dataset.resolve(resolved, function() {
return callback(true);
});

// Or... callback false to stop the synchronization process.
// return callback(false);

Expand Down
22 changes: 20 additions & 2 deletions dist/amazon-cognito.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/amazon-cognito.min.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
@@ -1,7 +1,8 @@
{
"name": "amazon-cognito-js",
"description": "Cognito Sync Manager for AWS JavaScript SDK",
"version": "1.0.0",
"main": "./dist/amazon-cognito.min.js",
"version": "1.1.0",
"author": {
"name": "Amazon Web Services",
"email": "aws@amazon.com",
Expand All @@ -22,13 +23,17 @@
}
],
"keywords": ["amazon","aws","cognito","identity","sync"],
"scripts": {
"build": "grunt bundle"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-qunit": "^0.5.2",
"grunt-contrib-uglify": "^0.6.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-jsdoc": "^0.5.7",
"grunt-umd": "^2.3.6",
"qunitjs": "^1.15.0"
}
}
2 changes: 1 addition & 1 deletion src/CognitoSyncDataset.js
Expand Up @@ -312,7 +312,7 @@ AWS.CognitoSyncManager.Dataset = (function() {

root.logger('Detecting last sync count... ' + syncCount);

if (syncCount == -1) {
if (parseInt(syncCount) === -1) {

// Dataset has been deleted locally
root.remote.deleteDataset(root.datasetName, function(err, data) {
Expand Down
5 changes: 3 additions & 2 deletions src/CognitoSyncLocalStorage.js
Expand Up @@ -232,7 +232,7 @@ AWS.CognitoSyncManager.LocalStorage = (function() {
this.getRecord(identityId, datasetName, key, function (err, record) {


if (record && record.getValue() == value) {
if (record && record.getValue() === value) {
// Record hasn't changed. All done.
return callback(null, record);
}
Expand Down Expand Up @@ -682,9 +682,10 @@ AWS.CognitoSyncManager.LocalStorage = (function() {
* @param identityId
* @param datasetName
* @param record
* @param callback
*/

CognitoSyncLocalStorage.prototype.removeRecord = function (identityId, datasetName, record) {
CognitoSyncLocalStorage.prototype.removeRecord = function (identityId, datasetName, record, callback) {
this.store.remove(identityId, datasetName, record, function (err) {
if (err) { return callback(err); }
return callback(null, true);
Expand Down