Directory structure :
Gulp code from GulpFile.js
gulp.task('test', function (done) {
karma.start({
configFile: _configFile: __dirname + '\\..\\test\\karma.conf.js',
singleRun: true
}, done);
});
So my problem going to the parent directory and access the karma.conf.js . For some reason the path is not get resolved with ..\\
to go back to the parent directory of WebApiRole . can someone point me in the right direction ?
__dirname: It is a local variable that returns the directory name of the current module. It returns the folder path of the current JavaScript file.
To go back 1 folder level with __dirname in Node. js, we can use the path. join method. const reqPath = path.
log(__dirname);//current directory where we open this folder. Now, we get our current directory but you are trying to move your directory one step back. You must use nodejs built in module path to work with directories. The method path.
I had to use path
package to resolve this issue .
var path = require("path"),
fs = require("fs");
gulp.task('test', function (done) {
karma.start({
configFile: fs.readFile(path.join(__dirname, '../test/', 'karma.conf.js')),
singleRun: true
}, done);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With