Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't add or remove XML declarations to/from first line of project fi…
- Loading branch information
Showing
12 changed files
with
81 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
export default function showPackagesQuickPick({ projFileFullPath, installedPackages, packageRefSection, parsed }: any): Thenable<any> { | ||
export default function showPackagesQuickPick({ | ||
projFileFullPath, | ||
installedPackages, | ||
packageRefSection, | ||
parsed, | ||
originalContents | ||
}: any): Thenable<any> { | ||
return vscode.window.showQuickPick(installedPackages) | ||
.then((selectedPackage: string | undefined) => ({ projFileFullPath, selectedPackage, parsed, packageRefSection })); | ||
.then((selectedPackage: string | undefined) => ({ | ||
projFileFullPath, | ||
selectedPackage, | ||
parsed, | ||
packageRefSection, | ||
originalContents | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const xmlDeclarationStart = '<?xml '; | ||
|
||
// NOTE: This method obviously does not check if the file actually is validly formatted XML. That | ||
// much is assumed. What's not assumed is that the first line is an XML declaration, which is what | ||
// this checks for. Good enough to close #29. | ||
export default function isHeadlessXML(candidateXML = '') { | ||
return candidateXML.slice(0, 6).toLowerCase() !== xmlDeclarationStart; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as expect from 'expect'; | ||
import { isHeadlessXML } from '../../src/utils'; | ||
|
||
export default function runIsHeadlessXMLTests() { | ||
describe('isHeadlessXML', function () { | ||
it('should return false only if the candidate string starts with \'<?xml \'', function () { | ||
expect(isHeadlessXML('')).toBe(true); | ||
expect(isHeadlessXML('some <?xml ')).toBe(true); | ||
expect(isHeadlessXML(' <?xml version="1.0" encoding="UTF-8" standalone="no" ?>')).toBe(true); | ||
expect(isHeadlessXML('<?xml')).toBe(true); | ||
expect(isHeadlessXML('<? xml')).toBe(true); | ||
expect(isHeadlessXML('<?xml ')).toBe(false); // this is ok; the utility assumes it's being given something "XML-like enough" | ||
expect(isHeadlessXML('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>')).toBe(false); | ||
}); | ||
}); | ||
} |