UNPKG

learnyounode

Version:

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

12 lines (9 loc) 361 B
'use strict' const fs = require('fs') const contents = fs.readFileSync(process.argv[2]) const 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