From 48002bc60144c25060bf91359620c4a0284e8284 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Wed, 8 Nov 2023 19:02:04 +0100 Subject: [PATCH] chore: remove touch as dev dependency (#5023) * chore: remove touch as dev dependency * Update test/integration/helpers.js --- package-lock.json | 48 ------------------------------------- package.json | 1 - test/integration/helpers.js | 10 ++++++-- 3 files changed, 8 insertions(+), 51 deletions(-) diff --git a/package-lock.json b/package-lock.json index 542c4097aa..a5c10334ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -94,7 +94,6 @@ "sinon": "^9.0.3", "strip-ansi": "^6.0.0", "svgo": "^1.3.2", - "touch": "^3.1.0", "unexpected": "^11.14.0", "unexpected-eventemitter": "^2.2.0", "unexpected-map": "^2.0.0", @@ -20914,33 +20913,6 @@ "integrity": "sha512-gVweAectJU3ebq//Ferr2JUY4WKSDe5N+z0FvjDncLGyHmIDoxgY/2Ie4qfEIDm4IS7OA6Rmdm7pdEEdMcV/xQ==", "dev": true }, - "node_modules/touch": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", - "dev": true, - "dependencies": { - "nopt": "~1.0.10" - }, - "bin": { - "nodetouch": "bin/nodetouch.js" - } - }, - "node_modules/touch/node_modules/nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", - "dev": true, - "dependencies": { - "abbrev": "1" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/tough-cookie": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", @@ -39255,26 +39227,6 @@ "integrity": "sha512-gVweAectJU3ebq//Ferr2JUY4WKSDe5N+z0FvjDncLGyHmIDoxgY/2Ie4qfEIDm4IS7OA6Rmdm7pdEEdMcV/xQ==", "dev": true }, - "touch": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", - "dev": true, - "requires": { - "nopt": "~1.0.10" - }, - "dependencies": { - "nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", - "dev": true, - "requires": { - "abbrev": "1" - } - } - } - }, "tough-cookie": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", diff --git a/package.json b/package.json index 8925811032..6da18b5cb8 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,6 @@ "sinon": "^9.0.3", "strip-ansi": "^6.0.0", "svgo": "^1.3.2", - "touch": "^3.1.0", "unexpected": "^11.14.0", "unexpected-eventemitter": "^2.2.0", "unexpected-map": "^2.0.0", diff --git a/test/integration/helpers.js b/test/integration/helpers.js index 3668089e2c..61c6ec01ca 100644 --- a/test/integration/helpers.js +++ b/test/integration/helpers.js @@ -7,7 +7,6 @@ const {format} = require('util'); const path = require('path'); const Base = require('../../lib/reporters/base'); const debug = require('debug')('mocha:test:integration:helpers'); -const touch = require('touch'); /** * Path to `mocha` executable @@ -479,6 +478,8 @@ async function runMochaWatchJSONAsync(args, opts, change) { ); } +const touchRef = new Date(); + /** * Synchronously touch a file. Creates * the file and all its parent directories if necessary. @@ -487,7 +488,12 @@ async function runMochaWatchJSONAsync(args, opts, change) { */ function touchFile(filepath) { fs.ensureDirSync(path.dirname(filepath)); - touch.sync(filepath); + try { + fs.utimesSync(filepath, touchRef, touchRef); + } catch (e) { + const fd = fs.openSync(filepath, 'a'); + fs.closeSync(fd); + } } /**