From 98bfdbaa06f32c3a6c05ce829be949cab39fd879 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Fri, 17 Feb 2023 06:50:27 +0100 Subject: [PATCH] Better install --- README.md | 4 +--- index.js | 6 ++++++ package-lock.json | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9f1a34c..efb3836 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,7 @@ _Helps locating elements in simple HTML pages_ ## Installation ```sh -git clone https://gitea.tforgione.fr/tforgione/locator -cd locator -npm install +npm install --global git+https://gitea.tforgione.fr/tforgione/locator.git ``` ## Usage diff --git a/index.js b/index.js index 5e6c453..16c629b 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,12 @@ const puppeteer = require('puppeteer'); async function main() { + if (process.argv[2] === undefined) { + console.error("This program expects an argument."); + console.error("USAGE: locator "); + process.exit(1); + } + // Path to the HTML file to analyse (given as relative path from current directory) // We need the full path so that puppeteer is able to access it const path = process.argv[2].startsWith('/') ? process.argv[2] : process.cwd() + '/' + process.argv[2]; diff --git a/package-lock.json b/package-lock.json index d47791a..6ccb661 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,9 @@ "license": "ISC", "dependencies": { "puppeteer": "^19.7.1" + }, + "bin": { + "locator": "index.js" } }, "node_modules/@babel/code-frame": {