phonegap-build
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -39,3 +39,3 @@ /* | ||
var configPath = path.join(paths.root, 'config.xml'); | ||
if (!path.existsSync(configPath)) { | ||
if (!fs.existsSync(configPath)) { | ||
configPath = path.join(paths.www, 'config.xml'); | ||
@@ -42,0 +42,0 @@ } |
@@ -52,6 +52,16 @@ /* | ||
var zipPath = path.resolve(buildPath, 'www.zip'), | ||
inputPath = path.resolve(wwwPath); | ||
inputPath = path.resolve(wwwPath), | ||
configPath = path.resolve(path.join(inputPath, '..', 'config.xml')), | ||
buildWWWPath = path.resolve(path.join(buildPath, 'www')); | ||
// copy my-app/www/ to <buildPath>/www/ directory | ||
shell.cp('-r', inputPath, buildPath); | ||
// copy my-app/config.xml to temp directory, when it exists | ||
if (fs.existsSync(configPath)) { | ||
shell.cp(configPath, buildWWWPath); | ||
} | ||
// shell out to zip. For windows, use native script. | ||
var cmd = util.format('zip -r "%s" "%s"', zipPath, inputPath); | ||
var cmd = util.format('zip -r "%s" "%s"', zipPath, buildWWWPath); | ||
@@ -63,3 +73,3 @@ if (os.type() === "Windows_NT") { | ||
zipPath, | ||
inputPath | ||
buildWWWPath | ||
); | ||
@@ -70,2 +80,5 @@ } | ||
// remove temporary www directory | ||
shell.rm('-r', buildWWWPath); | ||
// Change back to old directory due to implicit assumptions | ||
@@ -72,0 +85,0 @@ // on the current working directory elsewhere in the script. |
{ | ||
"name": "phonegap-build", | ||
"description": "PhoneGap Build node library.", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"homepage": "http://github.com/phonegap/node-phonegap-build", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -86,3 +86,3 @@ /* | ||
it('should fallback to my-app/config.xml', function() { | ||
spyOn(path, 'existsSync').andReturn(true); | ||
spyOn(fs, 'existsSync').andReturn(true); | ||
create(options, function(e, data) {}); | ||
@@ -89,0 +89,0 @@ expect(fs.readFile).toHaveBeenCalled(); |
@@ -24,5 +24,9 @@ /* | ||
spyOn(fs, 'exists'); | ||
spyOn(fs, 'existsSync'); | ||
spyOn(zip, 'cleanup'); | ||
spyOn(shell, 'mkdir'); | ||
spyOn(shell, 'cp'); | ||
spyOn(shell, 'exec').andReturn({ code: 0 }); | ||
spyOn(shell, 'rm'); | ||
spyOn(shell, 'cd'); | ||
}); | ||
@@ -65,2 +69,29 @@ | ||
it('should copy the www/ contents to the build directory', function() { | ||
zip.compress('./www', './build', function(e, path) {}); | ||
expect(shell.cp).toHaveBeenCalledWith( | ||
'-r', | ||
p.resolve('./www'), | ||
'./build' // @TODO we should resolve this path | ||
); | ||
}); | ||
it('should copy my-app/config.xml when it exists', function() { | ||
fs.existsSync.andReturn(true); | ||
zip.compress('./www', './build', function(e, path) {}); | ||
expect(shell.cp).toHaveBeenCalledWith( | ||
p.resolve('./config.xml'), | ||
p.resolve('./build/www') | ||
); | ||
}); | ||
it('should not copy my-app/config.xml when it does not exist', function() { | ||
fs.existsSync.andReturn(false); | ||
zip.compress('./www', './build', function(e, path) {}); | ||
expect(shell.cp).not.toHaveBeenCalledWith( | ||
p.resolve('./config.xml'), | ||
p.resolve('./build/www') | ||
); | ||
}); | ||
it('should try to zip the www directory', function() { | ||
@@ -83,3 +114,3 @@ zip.compress('./www', './build', function(e, path) {}); | ||
zip.compress('./www', './build', function(e, path) {}); | ||
expect(shell.exec.mostRecentCall.args[0]).toMatch(p.resolve('./www')); | ||
expect(shell.exec.mostRecentCall.args[0]).toMatch(p.resolve('./build/www')); | ||
expect(shell.exec.mostRecentCall.args[0]).toMatch(p.resolve('./build')); | ||
@@ -91,3 +122,3 @@ }); | ||
expect(shell.exec.mostRecentCall.args[0]).toMatch( | ||
p.resolve('./path/to the/www') | ||
p.resolve('build/www.zip') | ||
); | ||
@@ -117,3 +148,3 @@ }); | ||
expect(shell.exec.mostRecentCall.args[0]).toMatch( | ||
p.resolve('./path/to the/www') | ||
p.resolve('build/www.zip') | ||
); | ||
@@ -120,0 +151,0 @@ }); |
1504745
5891