diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8410891 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: "Release to Marketplace" + +on: + push: + tags: + - "v*" + +jobs: + release: + runs-on: "ubuntu-latest" + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Setup NodeJS" + uses: "actions/setup-node@v2.1.0" + + - name: "Install Dependencies" + run: "npm install" + + - name: "Run Tests" + run: "npm run test" + + - name: "Publish to Marketplace" + uses: "sigma/vsce-publish-action@v0.0.2" + with: + vsce_token: ${{ secrets.VSCE_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..15d66f0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: "Run Tests" + +on: + pull_request: + branches: + - "master" + +jobs: + test: + runs-on: "ubuntu-latest" + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Setup NodeJS" + uses: "actions/setup-node@v2.1.0" + + - name: "Install Dependencies" + run: "npm install" + + - name: "Run Tests" + run: "npm run test" diff --git a/package.json b/package.json index 50f1d87..3000246 100644 --- a/package.json +++ b/package.json @@ -261,7 +261,8 @@ "compile": "npm run lint && tsc -p ./", "watch": "tsc -watch -p ./", "postinstall": "node ./node_modules/vscode/bin/install", - "test": "npm run compile && mocha ./out/test/**/*.js", + "test": "npm run compile && mocha './out/test/**/*.js'", + "test-windows": "npm run compile && mocha ./out/test/**/*.js", "lint": "tslint -p tslint.json --fix" }, "devDependencies": { @@ -277,4 +278,4 @@ "xpath": "0.0.27", "xqlint": "^0.4.1" } -} +} \ No newline at end of file diff --git a/src/formatting/commands/textToXml.ts b/src/formatting/commands/textToXml.ts index 0b9dec0..cf6c4ef 100644 --- a/src/formatting/commands/textToXml.ts +++ b/src/formatting/commands/textToXml.ts @@ -23,6 +23,7 @@ export function textToXml(textEditor: TextEditor): void { .replace(/</g, "<") .replace(/>/g, ">") .replace(/&/g, "&") + // tslint:disable-next-line .replace(/"/g, '"') .replace(/'/g, "'"); diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 77ef70e..640ec47 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -124,19 +124,21 @@ describe("V2XmlFormatter", () => { }); function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`); + const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`).replace(/\r/g, ""); const unformattedXml = TestDataLoader.load(`${fileLabel}.unformatted.xml`); - const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options); + const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/g, ""); - assert.equal(actualFormattedXml, expectedFormattedXml, "Actual formatted XML does not match expected formatted XML."); + // tslint:disable-next-line + assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml.replace(/\s/, "~ws~")}\n\nEXPECTED\n${expectedFormattedXml.replace(/\s/, "~ws~")}`); } function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`); + const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`).replace(/\r/g, ""); const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`); - const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options); + const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/g, ""); - assert.equal(actualMinifiedXml, expectedMinifiedXml, "Actual minified XML does not match expected minified XML."); + // tslint:disable-next-line + assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml.replace(/\s/, "~ws~")}\n\nEXPECTED\n${expectedMinifiedXml.replace(/\s/, "~ws~")}`); }