canvas-data-cli
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -5,4 +5,8 @@ 'use strict'; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var apiAuth = require('./apiAuth'); | ||
@@ -15,2 +19,16 @@ var url = require('url'); | ||
var ApiError = (function (_Error) { | ||
_inherits(ApiError, _Error); | ||
function ApiError(msg, errorCode, resp) { | ||
_classCallCheck(this, ApiError); | ||
_get(Object.getPrototypeOf(ApiError.prototype), 'constructor', this).call(this, msg); | ||
this.errorCode = errorCode; | ||
this.resp = resp; | ||
} | ||
return ApiError; | ||
})(Error); | ||
var Api = (function () { | ||
@@ -52,3 +70,3 @@ function Api(config) { | ||
} | ||
return cb(new Error('invalid status code, got ' + resp.statusCode + ': ' + message)); | ||
return cb(new ApiError('invalid status code, got ' + resp.statusCode + ': ' + message, resp.statusCode, body)); | ||
} | ||
@@ -55,0 +73,0 @@ cb(null, body); |
@@ -99,3 +99,3 @@ 'use strict'; | ||
logger.error(err); | ||
if (err.stack) logger.error(err.stack); | ||
if (err.stack && !err.silence) logger.error(err.stack); | ||
process.exit(1); | ||
@@ -102,0 +102,0 @@ } |
@@ -94,4 +94,10 @@ 'use strict'; | ||
this.api.getSync(function (err, toSync) { | ||
if (err && err.errorCode === 404) { | ||
_this2.logger.error('no files exist for account, cannot sync'); | ||
err.silence = true; | ||
return cb(err); | ||
} | ||
if (err) return cb(err); | ||
if (toSync.incomplete) _this2.logger.warn('Could not retrieve a full list of files! Some incremental data will be missing!'); | ||
_this2.logger.info('total number of files: ' + toSync.files.length + ' files'); | ||
@@ -98,0 +104,0 @@ cb(null, toSync); |
{ | ||
"name": "canvas-data-cli", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "A CLI tool for interacting with the Canvas Data API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,3 @@ # Canvas Data CLI | ||
### OR Install from github | ||
`git clone https://github.com/instructure/canvas-data-cli.git && cd canvas-data-cli && make localInstall` | ||
`git clone https://github.com/instructure/canvas-data-cli.git && cd canvas-data-cli && make installLocal` | ||
### Configuring | ||
@@ -16,0 +16,0 @@ The Canvas Data CLI requires a configuration file with a fields set. Canvas Data CLI uses a small javascript file as configuration file. |
59932
1334