Fixed: Ask Node for a temporary directory instead of using '/tmp'

This commit is contained in:
Martin Carlberg
2021-09-17 09:38:29 +02:00
parent 653dd07162
commit fdff92e5c8
2 changed files with 6 additions and 19 deletions
+3 -17
View File
@@ -36,6 +36,7 @@
var path = require("path");
var fs = require("fs");
var os = require("os");
var child_process = require("child_process");
var utilsFile = ObjectiveJ.utils.file;
@@ -124,28 +125,13 @@ ConverterConversionException = @"ConverterConversionException";
if ([outputPath length])
{
// Compile xib or nib to make sure we have a non-new format nib.
temporaryNibFilePath = path.join("/tmp", path.basename(aFilePath) + ".tmp.nib");
//temporaryNibFilePath = FILE.join("/tmp", FILE.basename(aFilePath) + ".tmp.nib");
temporaryNibFilePath = path.join(os.tmpDir(), path.basename(aFilePath) + ".tmp.nib");
try {
child_process.execSync("/usr/bin/ibtool" + " " + aFilePath + " " + "--compile" + " " + temporaryNibFilePath, {stdio: 'inherit'});
} catch(err) {
[CPException raise:ConverterConversionException reason:@"Could not compile file: " + aFilePath];
}
/* try
{
var p = OS.popen(["/usr/bin/ibtool", aFilePath, "--compile", temporaryNibFilePath]);
if (p.wait() === 1)
[CPException raise:ConverterConversionException reason:@"Could not compile file: " + aFilePath];
}
finally
{
p.stdin.close();
p.stdout.close();
p.stderr.close();
} */
}
else
{
@@ -160,7 +146,7 @@ ConverterConversionException = @"ConverterConversionException";
}
// Convert from binary plist to XML plist
var temporaryPlistFilePath = path.join("/tmp", path.basename(aFilePath) + ".tmp.plist");
var temporaryPlistFilePath = path.join(os.tmpDir(), path.basename(aFilePath) + ".tmp.plist");
try {
child_process.execSync("/usr/bin/plutil" + " " + "-convert" + " " + "xml1" + " " + (temporaryNibFilePathInDirectoryFile || temporaryNibFilePath) + " " + "-o" + " " + temporaryPlistFilePath, {stdio: 'inherit'});
+3 -2
View File
@@ -26,6 +26,7 @@
var fs = require("fs");
var os = require("os");
var path = require("path");
@implementation CPCib (NSCoding)
@@ -47,8 +48,8 @@ var os = require("os");
}
self = [super init];
// FIXME: change /tmp/ to os.tmpDir() in Node
var nibPath = @"/tmp/" + "nib2cib-" + generateID(40) + ".nib",
var nibPath = path.join(os.tmpDir(), "nib2cib-" + generateID(40) + ".nib"),
data = [aCoder decodeObjectForKey:@"NSNibFileData"];
fs.writeFileSync(nibPath, new Uint8Array(data.bytes()), { encoding: "utf16le" });