Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Store packed file contents in base64 (no need to escape unicode chara…

…cters anymore).
  • Loading branch information...
commit 473dc13dcff766c7be83e5d0ce6cdf882300931f 1 parent b1ae0cf
@farhadi farhadi authored
Showing with 5 additions and 7 deletions.
  1. +1 −3 cli/command.js
  2. +3 −3 cli/pack.js
  3. +1 −1  lib/archive.js
View
4 cli/command.js
@@ -177,9 +177,7 @@ function loadManifest(manifest_path, conf) {
function generate_resource(input_dir, output_dir, manifest){
util.log('Generating package...');
- var content = JSON.stringify(pack.generate(input_dir,manifest)).replace(/[^\x00-\x7F]/g, function(chr) {
- return '\\u' + ('000' + chr.charCodeAt(0)).substr(-4);
- });
+ var content = JSON.stringify(pack.generate(input_dir,manifest));
var resource_path = path.resolve(output_dir,'resources.json');
if (manifest.embed) {
content = 'module.exports = ' + content;
View
6 cli/pack.js
@@ -54,7 +54,7 @@ var addDir = function(dir,root_dir) {
if( err ) throw err;
var relpath = path.relative(root_dir,file);
- packageObj[relpath] = fs.readFileSync(file).toString();
+ packageObj[relpath] = fs.readFileSync(file).toString('base64');
});
}
@@ -64,13 +64,13 @@ addFileEntry = function(entry_path,root_dir){
var entry = path.join(root_dir,entry_path);
var rentry = path.relative(root_dir,entry);
- packageObj[rentry] = fs.readFileSync(entry).toString();
+ packageObj[rentry] = fs.readFileSync(entry).toString('base64');
}
addEntry = function(p,content,root_dir){
var rentry = path.relative(root_dir,p);
- packageObj[rentry] = content.toString();
+ packageObj[rentry] = Buffer(content).toString('base64');
}
View
2  lib/archive.js
@@ -48,7 +48,7 @@ exports.hasEntry = function(path){
exports.getEntry = function(path){
if(typeof resource[path] == 'string')
- resource[path] = new Buffer(resource[path]);
+ resource[path] = new Buffer(resource[path], 'base64');
return resource[path];
}
Please sign in to comment.
Something went wrong with that request. Please try again.