-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
42 lines (33 loc) · 1.28 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var path = require('path');
var fs = require('fs');
var edge = require('edge');
var libDir = path.join(__dirname, 'lib');
var nodeDymoLib = path.join(libDir, 'NodeDymoLib.dll');
var dymoLibPath = path.join('C:', 'Program Files (x86)', 'DYMO', 'DYMO Label Software', 'Framework', '.net4');
dymoAssemblies = [ 'DYMO.Label.Framework.dll', 'DYMO.DLS.Runtime.dll', 'DYMO.Common.dll' ];
if (!fs.existsSync(dymoLibPath + "/DYMO.LABEL.Framework.dll")) {
dymoLibPath = path.join(dymoLibPath, "..");
}
var called = 0;
var initDymoLib = function() {
if (++called < dymoAssemblies.length) return false;
var printers = module.exports.printers = edge.func({
assemblyFile: nodeDymoLib,
typeName: 'NodeDymoLib.Dymo',
methodName: 'Printers'
});
var print = module.exports.print = edge.func({
assemblyFile: nodeDymoLib,
typeName: 'NodeDymoLib.Dymo',
methodName: 'Print'
});
}
for (var f of dymoAssemblies) {
var source = path.join(dymoLibPath, f), target = path.join(libDir, f);
var readStream = fs.createReadStream(source);
var writeStream = fs.createWriteStream(target);
readStream.on('error', function(err) { throw err });
writeStream.on('error', function(err) { throw err });
writeStream.on('finish', initDymoLib);
readStream.pipe(writeStream);
}