securityos/node_modules/shell-parse/tests/variable-assignment.js

29 lines
628 B
JavaScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
var test = require('tape');
var parse = require('../parser');
test('Standalone variable assignments', function (t) {
t.deepEqual(parse('a="b"'), [{
type: 'variableAssignment',
name: 'a',
value: { type: 'literal', value: 'b' },
control: ';',
next: null
}]);
t.end();
});
test('Variable assignments before command', function (t) {
t.deepEqual(parse('a="b" some-command'), [{
type: 'command',
command: { type: 'literal', value: 'some-command' },
args: [],
redirects: [],
env: {
a: { type: 'literal', value: 'b' }
},
control: ';',
next: null
}]);
t.end();
});