UNPKG

learnyounode

Version:

Learn You The Node.js For Much Win! An intro to Node.js via a set of self-guided workshops.

10 lines (8 loc) 341 B
var fs = require('fs') var contents = fs.readFileSync(process.argv[2]) var lines = contents.toString().split('\n').length - 1 console.log(lines) // note you can avoid the .toString() by passing 'utf8' as the // second argument to readFileSync, then you'll get a String! // // fs.readFileSync(process.argv[2], 'utf8').split('\n').length - 1