Skip to content

Commit

Permalink
adding a XAML reformatter/beautifier tool to help ensure that we can …
Browse files Browse the repository at this point in the history
…have all XAML files formatted and cleaned consistently.
  • Loading branch information
GerHobbelt committed Dec 30, 2019
1 parent 39f6147 commit 19fd245
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
17 changes: 17 additions & 0 deletions Qiqqa.Build/beautify-xaml.js
@@ -0,0 +1,17 @@

var beautify = require('xml-beautifier');
var fs = require('fs');
var path = require('path');

const xml = beautify('<div><span>foo</span></div>');
console.log(xml); // => will output correctly indented elements

var xaml_list = [].concat(process.argv).slice(2);
console.log(xaml_list);

foreach(var source_file in xaml_list) {
console.log(`processing file ${source_file}:");
var src = fs.readFileSync(source_file, 'utf8');
var dst = beautify(src);
fs.writeFileSync(source_file, dst, 'utf8');
}
Expand Up @@ -13,9 +13,9 @@

<DockPanel DockPanel.Dock="Bottom">
<local_gui:AugmentedSpacer DockPanel.Dock="Right" />
<local_gui:AugmentedButton DockPanel.Dock="Right" Name="CmdGenerate" MinHeight="20" />
<local_gui:AugmentedButton DockPanel.Dock="Right" Name="CmdGenerate" MinHeight="20" MinWidth="100" />
<local_gui:AugmentedSpacer DockPanel.Dock="Right" />
<local_gui:AugmentedButton DockPanel.Dock="Right" Name="CmdCancel" MinHeight="20" />
<local_gui:AugmentedButton DockPanel.Dock="Right" Name="CmdCancel" MinHeight="20" MinWidth="100" />
<Grid/>
</DockPanel>

Expand Down
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -38,5 +38,8 @@
"globby": "^10.0.1",
"moment": "^2.24.0",
"semver": "^6.3.0"
},
"devDependencies": {
"xml-beautifier": "^0.4.2"
}
}
5 changes: 5 additions & 0 deletions xaml-beautify.sh
@@ -0,0 +1,5 @@
#! /bin/bash
#

find . -type f -iname '*.xaml' | xargs node Qiqqa.Build/beautify-xaml.js

0 comments on commit 19fd245

Please sign in to comment.