From 4d06de758fcc28016ea76664692416a135b39e80 Mon Sep 17 00:00:00 2001 From: David GABISON Date: Sun, 22 Jan 2023 21:54:28 +0100 Subject: [PATCH] dev: update package.json --- package.json | 50 ++++++++++++++++++++++++++++---------------------- watch.js | 16 ++++++++++++++++ 2 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 watch.js diff --git a/package.json b/package.json index fd44f15..a1ff047 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,30 @@ { - "name": "obsidian-sample-plugin", - "version": "1.0.1", - "description": "This is a sample plugin for Obsidian (https://obsidian.md)", - "main": "main.js", - "scripts": { - "dev": "node esbuild.config.mjs", - "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", - "version": "node version-bump.mjs && git add manifest.json versions.json" - }, - "keywords": [], - "author": "", - "license": "MIT", - "devDependencies": { - "@types/node": "^16.11.6", - "@typescript-eslint/eslint-plugin": "^5.2.0", - "@typescript-eslint/parser": "^5.2.0", - "builtin-modules": "^3.2.0", - "esbuild": "0.13.12", - "obsidian": "latest", - "tslib": "2.3.1", - "typescript": "4.4.4" - } + "name": "obsidian-sample-plugin", + "version": "1.0.0", + "description": "This plugin manage aliases of notes in Obsidian.", + "main": "main.js", + "scripts": { + "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", + "dev": "node esbuild.config.mjs", + "start": "run-p watch dev", + "version": "node version-bump.mjs && git add manifest.json versions.json", + "watch": "node ./watch.js" + }, + "keywords": [], + "author": "pulsovi", + "license": "GNU AGPLv3", + "devDependencies": { + "@types/node": "^16.11.6", + "@typescript-eslint/eslint-plugin": "^5.2.0", + "@typescript-eslint/parser": "^5.48.2", + "builtin-modules": "^3.2.0", + "esbuild": "0.13.12", + "eslint": "^8.32.0", + "eslint-config-pulsovi-typescript": "^0.4.0", + "npm-run-all": "^4.1.5", + "obsidian": "latest", + "tslib": "2.3.1", + "typescript": "^4.9.4" + }, + "packageManager": "yarn@3.3.1" } diff --git a/watch.js b/watch.js new file mode 100644 index 0000000..af0e5c8 --- /dev/null +++ b/watch.js @@ -0,0 +1,16 @@ +const fs = require('fs'); +const path = require('path'); + +let timeoutId = null; +const watcher = fs.watch('./main.js', { persistent: true }, (event, filename) => { + clearTimeout(timeoutId); + timeoutId = setTimeout(() => handleEvent(event, filename), 200); +}); + +function handleEvent (event, filename) { + console.log(event, filename); + const src = path.resolve('./main.js'); + const dest = `${process.argv[2]}/main.js`; + console.log('copy file', src, 'to', dest); + fs.copyFile(src, dest, (err) => {console.log(err)}); +}