Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nstonehouse/remove libxmljs #10

Merged
merged 2 commits into from
Dec 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/loadByFileSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

var fs = require( 'fs' ),
path = require( 'path' ),
et = require('elementtree');
et = require('elementtree'),
stripBom = require('strip-bom');

module.exports = function( packagePath ) {

var dir = path.dirname( packagePath );

var xml = et.parse(
fs.readFileSync(
stripBom(fs.readFileSync(
packagePath,
{ encoding: "UTF-8" }
)
{ encoding: "utf8" }
))
);

var filePaths = { JavaScript: [], Css: [] };
Expand Down
9 changes: 5 additions & 4 deletions lib/loadDefinitionSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

var fs = require('fs'),
path = require('path'),
et = require('elementtree');
et = require('elementtree'),
stripBom = require('strip-bom');

module.exports = function( definitionPath ) {

var dir = path.dirname( definitionPath );

var xml = et.parse(
fs.readFileSync(
stripBom(fs.readFileSync(
definitionPath,
{ encoding: "UTF-8" }
).toString()
{ encoding: "utf8" }
))
);

var pathsFiles = xml.findall('.//Paths/*');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"elementtree": "^0.1.6",
"q": "^1.0.1",
"q-io": "^1.11.5",
"strip-bom": "^1.0.0",
"xml2js": "^0.4.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion test/data/invalidxml.package.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
invalid XML!
invalid XML!
2 changes: 1 addition & 1 deletion test/data/packages/definition1.definition.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Package Name="TestPackage1" HasCss="false" HasJavaScript="true">
<Paths>
<File Path="../test1.package.xml" />
Expand Down
14 changes: 7 additions & 7 deletions test/data/packages/definition2.definition.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Package Name="TestPackage2" HasCss="false" HasJavaScript="true">
<Paths>
<File Path="c:\abc\test1.package.xml" />
<File Path="/abc/test1.package.xml" />
</Paths>
</Package>
<?xml version="1.0" encoding="utf-8"?>
<Package Name="TestPackage2" HasCss="false" HasJavaScript="true">
<Paths>
<File Path="c:\abc\test1.package.xml" />
<File Path="/abc/test1.package.xml" />
</Paths>
</Package>
2 changes: 1 addition & 1 deletion test/data/packages/definition3.definition.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Package Name="TestPackage3" HasCss="false" HasJavaScript="true">
<Paths>
<File/>
Expand Down
2 changes: 1 addition & 1 deletion test/data/packages/invalidxml.definition.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
invalid XML!
invalid XML!
2 changes: 1 addition & 1 deletion test/data/test1.package.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Package Name="TestPackage1" xmlns="http://schemas.desire2learn.com/xml/schemas/package.xsd">
<Package Name="TestPackage1" xmlns="http://schemas.desire2learn.com/xml/schemas/package.xsd">
<Css>
<File Path="file1.css" />
<File Path="file2.css" />
Expand Down
2 changes: 1 addition & 1 deletion test/data/test2.package.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Package Name="TestPackage1" xmlns="http://schemas.desire2learn.com/xml/schemas/package.xsd">
<Package Name="TestPackage2" xmlns="http://schemas.desire2learn.com/xml/schemas/package.xsd">
<Css>
<File Path="file3.css" />
<File Path="file4.css" />
Expand Down
2 changes: 1 addition & 1 deletion test/data/test3.package.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Package Name="TestPackage3" xmlns="http://schemas.desire2learn.com/xml/schemas/package.xsd">
<Package Name="TestPackage3" xmlns="http://schemas.desire2learn.com/xml/schemas/package.xsd">
<JavaScript>
<File Path="file3.js" />
<File Path="file4.js" />
Expand Down
2 changes: 1 addition & 1 deletion test/data/test4.package.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Package Name="TestPackage4" xmlns="http://schemas.desire2learn.com/xml/schemas/package.xsd">
<Package Name="TestPackage4" xmlns="http://schemas.desire2learn.com/xml/schemas/package.xsd">
<Css>
<File Path="file3.css" />
<File Path="file4.css" />
Expand Down