aboutsummaryrefslogtreecommitdiff
path: root/examples/defvar.js
blob: ec92fbc6e05db889a3da292892bc4b3945949d83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var libaugeas = require('../build/Release/libaugeas');

var createAugeas = libaugeas.createAugeas;

var aug = createAugeas();

aug.defvar('thing', '/files/etc/hosts'); // set "thing" = /files/etc/hosts

console.log(aug.get('$thing/1/ipaddr')); // use "thing"

aug.defvar('thing'); // delete "thing"

// Throws exception:
try {
    console.log(aug.get('$thing/1/ipaddr'));
} catch(err) {
    console.log('Ok, caught: ' + err);
}