2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-11 07:41:04 +00:00
nativefier/tempDir.js

52 lines
1.1 KiB
JavaScript

/**
* Created by JiaHao on 5/7/15.
*/
var fs = require('fs');
var temp = require('temp').track();
var ncp = require('ncp').ncp;
/**
* @callback tempDirCallback
* @param error
* @param tempDirPath
*/
/**
* Creates a temporary directory and copies the './app folder' inside, and adds a text file with the configuration
* for the single page app.
*
* @param {string} name
* @param {string} targetURL
* @param {boolean} badge
* @param width
* @param height
* @param {tempDirCallback} callback
*/
module.exports = function (name, targetURL, badge, width, height, callback) {
var tempDir = temp.path();
ncp(__dirname + '/app', tempDir, function (error) {
if (error) {
console.error(error);
callback('Error Copying temporary directory\n' + error, null);
} else {
var appArgs = {
name: name,
targetUrl: targetURL,
badge: badge,
width: width,
height: height
};
fs.writeFileSync(tempDir + '/targetUrl.txt', JSON.stringify(appArgs));
callback(error, tempDir);
}
});
};