forked from Azure/iothub-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iothub-explorer-logout.js
37 lines (30 loc) · 946 Bytes
/
iothub-explorer-logout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
// Native node modules
var fs = require('fs');
var path = require('path');
// External dependencies
var program = require('commander');
// Local dependencies
var printErrorAndExit = require('./common.js').printErrorAndExit;
var printSuccess = require('./common.js').printSuccess;
var configLoc = require('./common.js').configLoc;
program
.description('Terminate a temporary session on your IoT hub')
.parse(process.argv);
var loc = configLoc();
var path = path.join(loc.dir, loc.file);
try {
fs.unlinkSync(path);
printSuccess('Session successfully terminated.');
printSuccess('Removed session file: ' + path);
}
catch (err) {
if (err.code === 'ENOENT') {
printErrorAndExit('No session information found.');
} else {
throw err;
}
}