dailylog 7-23-20

less than 1 minute read

https://marketplace.visualstudio.com/items?itemName=satokaz.vscode-markdown-header-coloring

const fs = require("fs");

fs.readdir(".", (err, filenames) => {
  if (err) {
    console.log(err);
  }
  console.log(filenames);
});
const fs = require("fs");

fs.readdir(process.cwd(), (err, filenames) => {
  if (err) {
    console.log(err);
  }
  console.log(filenames);
});

ADD EXECUTABLE TO PACKAGE.JSON FILE

  "bin": {
    "name-of-executable": "index.js"
  }

To actually be able to link and run a project we have to:

  1. npm init -y
  2. create index.js with a console log or something
  3. Create package.json with ‘bin’ section
  4. Change index.js file permissions –> chmod +x index.js
  5. Add a comment to index.js to allow it to be treated like an executable –> #!/usr/bin/env node
  6. Link the project –> npm link
    1. (Issues linking the project required me to give super user permissions to node libraries ) SO
    2. sudo chown -R $USER /usr/local/lib/node_modules

Is it a File or a Folder?

lstat

JAVASCRIPT TRICKS!! const allStats = Array(filenames.length).fill(null)

myArray.every(takes iterator function)

allStats.every((stats) => {
  return stats;
});

NOTES: proceess.argv[2]