mirror of
https://github.com/zhigang1992/firebase-tools.git
synced 2026-05-25 18:31:37 +08:00
* -s is now --non-interactive * firebase-cli with options but no command no longer hangs * login doesn't run in non-interactive mode * config is now materialized according to the new world specs * config and firebase name are applied in before filters
37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
var Command = require('../lib/command');
|
|
var requireAccess = require('../lib/requireAccess');
|
|
var request = require('request');
|
|
var api = require('../lib/api');
|
|
var responseToError = require('../lib/responseToError');
|
|
var FirebaseError = require('../lib/error');
|
|
var RSVP = require('rsvp');
|
|
var utils = require('../lib/utils');
|
|
var querystring = require('querystring');
|
|
|
|
module.exports = new Command('data:remove <path>')
|
|
.description('remove data from your Firebase at the specified path')
|
|
.option('-f, --firebase <app>', 'override the app specified in firebase.json')
|
|
.option('-a, --auth <token>', 'authorization token to use (defaults to admin token)')
|
|
.before(requireAccess)
|
|
.action(function(path, options) {
|
|
return new RSVP.Promise(function(resolve, reject) {
|
|
var url = utils.addSubdomain(api.realtimeOrigin, options.firebase) + path + '.json?';
|
|
var query = {auth: options.auth || options.dataToken};
|
|
|
|
url += querystring.stringify(query);
|
|
|
|
request.del(url, {json: true}, function(err, res, body) {
|
|
if (err) {
|
|
return reject(new FirebaseError('Unexpected error while removing data', {exit: 2}));
|
|
} else if (res.statusCode >= 400) {
|
|
return reject(responseToError(res, body));
|
|
}
|
|
|
|
utils.logSuccess('Data removed successfully');
|
|
return resolve();
|
|
});
|
|
});
|
|
});
|