Answer the question
In order to leave comments, you need to log in
What's wrong with including node js module?
The first run of the bg.js script goes without problems, but after a reboot an error occurs:
Error: Invocation of form nw.Window.open(string, , function) doesn't match definition nw.Window.open(string url, optional object options, optional function callback) at Object.normalizeArgumentsAndValidate(extensions::schemaUtils:112:11) at Object. (extensions::binding:414:30) at Promise (D:\wasa2\documents\projects\postup\lib\wn_.js:5:19) at Object.exports.winOpen (D:\wasa2\documents\projects\ postup\lib\wn_.js:4:12) at fl.checkPath.catch.then (chrome-extension://icbbpfpgimfaggfemjancddfhmipjkjm/bg.js:22:19)
and if everything is collected in one file it works without problems.
bg.js:
'use strict';
var fs = require('fs'),
wn = require('D:\\wasa2\\documents\\projects\\postup\\lib\\wn_.js'),
fl = require('D:\\wasa2\\documents\\projects\\postup\\lib\\fl_.js').fl,
path_ = nw.App.dataPath + '\\user_',
set = {
"title": "PostUP",
"show": true
};
fl.checkPath(path_)
.catch((ans) => {
console.dir(ans);
if (ans.code === 'ENOENT') {
return fl.greatePath(path_);
} else {
return Promise.reject(ans);
}
})
.then(() => {
return wn.winOpen('D:\\wasa2\\documents\\projects\\postup\\html\\index.html', set);
})
.then((w) => {
console.dir(w);
})
.catch((ans) => {
console.dir(ans);
});
'use strict';
//проверка наличия папки с настройками
exports.fl = {
checkPath: (path) => {
return new Promise((resolve, reject) => {
fs.stat(path_, (err, data) => {
if (data) {
resolve(data);
} else {
reject(err);
}
});
});
},
//создаем папку
greatePath: (path) => {
return new Promise((resolve, reject) => {
fs.mkdir(path_, (data) => {
if (data) {
resolve(data);
} else {
reject(data);
}
});
});
}
}
'use strict';
exports.winOpen = (url, setings) => {
return new Promise((resolve, reject) => {
nw.Window.open(url, setings, function(w) {
if (w) resolve(w);
else reject();
});
});
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question