Skip to content

Commit

Permalink
fix(#293): print
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Jun 5, 2024
1 parent 06fae0c commit c737899
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/commands/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const {mvnw, flags} = require('../mvnw');

/**
* Command to convert .XMIR files into .EO files.
* @param {Hash} opts - All options
* @param {Object} opts - All options
* @return {Promise} of assemble task
*/
module.exports = function(opts) {
const input = path.resolve(opts.target, '2-optimize');
const input = path.resolve(opts.target, opts.printInput);
console.debug('Reading from %s', rel(input));
const output = path.resolve(opts.target, 'print');
const output = path.resolve(opts.target, opts.printOutput);
console.debug('Writing into %s', rel(output));
return mvnw(
['eo:print']
Expand Down
12 changes: 11 additions & 1 deletion src/eoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,19 @@ program.command('unphi')

program.command('print')
.description('Generate EO files from XMIR files')
.option(
'--print-input',
'Directory where XMIR files for translation to EO are taken (relative to --target)',
'2-optimize'
)
.option(
'--print-output',
'Directory where translated EO files are stored (relative to --target)',
'print'
)
.action((str, opts) => {
clear(str);
print(program.opts());
print({...program.opts(), ...str});
});

program.command('verify')
Expand Down
8 changes: 5 additions & 3 deletions test/commands/test_print.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ describe('print', function() {
it('converts XMIR files to EO files', function(done) {
const home = path.resolve('temp/test-print/simple');
fs.rmSync(home, {recursive: true, force: true});
fs.mkdirSync(path.resolve(home, 'target/2-optimize'), {recursive: true});
fs.mkdirSync(path.resolve(home, 'target/input'), {recursive: true});
fs.writeFileSync(
path.resolve(home, 'target/2-optimize/app.xmir'),
path.resolve(home, 'target/input/app.xmir'),
[
'<program ms="0" name="xx" time="2024-01-01T01:01:01"',
'version="0.0.0" dob="2024-01-01T01:01:01" revision="0">',
Expand All @@ -47,12 +47,14 @@ describe('print', function() {
'--track-optimization-steps',
'--parser=' + parserVersion,
'--home-tag=' + homeTag,
'--print-input=input',
'--print-output=output',
'-t', path.resolve(home, 'target'),
]);
assertFilesExist(
stdout, home,
[
'target/print/app.eo',
'target/output/app.eo',
]
);
done();
Expand Down

0 comments on commit c737899

Please sign in to comment.