Author: Kavit

0

–nt file test operator in bash

File based con­di­tion for if state­ments in bash Con­di­tion: [ new­er­file –nt old­er­file ] Descrip­tion: new­er­file was changed more recently than old­er­file, or if new­er­file exists and old­er­file doesn’t. Exam­ple: if [ file1.txt –nt file2.txt…

0

Stubbing a class without invoking a constructor

You can cre­ate Stub instances using sinon.createStubInstance. const sinon = require(‘sinon’); const Foo = require(‘../Foo.js’); const fooS­tub = sinon.createStubInstance(Foo); fooStub.foo { bar() { returns ‘bar’; } } expect(fooStub.foo.bar()).to.equal(‘bar’);

0

How to read a file as a string in nodejs javascript?

Below code reads the file con­tent in asyn­chro­nous man­ner and the con­tent is returned in the string for­mat and buffered for­mat respec­tively. let fs = require(“fs-extra”); let path = require(“path”); fs.readFile(path.join(__dirname, “filePath”), “utf8”,(data, err)…

0

How to run cpplint on recursively on multiple folders?

You can spec­ify path to both the direc­to­ries as argu­ments. In this exam­ple, they are spec­i­fied as src­Files and app­Files. const cppLint = path.resolve(“cpplint.py”); // get the path to cpplint.py const src­Files = path.resolve(__dirname,…

0

Debug mocha using visual studio code

Add the fol­low­ing con­fig­u­ra­tion in your launch.json { “name”: “Run mocha”, “type”: “node”, “request”: “launch”, “pro­gram”: “${workspaceRoot}/node_modules/mocha/bin/mocha”, “sto­pO­nEn­try”: false, “args”: [ “test/**/*.js”, “–inspect”, “–debug-brk”, “–no-timeouts” ], “cwd”: “${work­space­Root}”, “run­time­Ex­e­cutable”: null, “env”: { “NODE_ENV”: “testing”…