1
0
mirror of https://github.com/jiahaog/Nativefier synced 2024-06-30 08:10:49 +02: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);
}
});
};