This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-serve.git


The following commit(s) were added to refs/heads/master by this push:
     new 9b1d9f7  chore: various changes (#74)
9b1d9f7 is described below

commit 9b1d9f747d2303832529964fb6fdf5a12ca081d0
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Thu Aug 21 13:26:38 2025 +0900

    chore: various changes (#74)
    
    * chore: use node:* prefix
    * chore: remove globals Promise comment line
    * chore(main): convert CordovaServe to class
---
 src/browser.js  |  6 ++----
 src/exec.js     |  4 +---
 src/main.js     | 50 +++++++++++++++++++++++++-------------------------
 src/platform.js |  4 +---
 src/server.js   |  2 --
 src/util.js     |  4 ++--
 6 files changed, 31 insertions(+), 39 deletions(-)

diff --git a/src/browser.js b/src/browser.js
index a531fa0..ee0167f 100644
--- a/src/browser.js
+++ b/src/browser.js
@@ -17,10 +17,8 @@
     under the License.
 */
 
-/* globals Promise: true */
-
-const child_process = require('child_process');
-const fs = require('fs');
+const child_process = require('node:child_process');
+const fs = require('node:fs');
 const open = require('open');
 const which = require('which');
 const exec = require('./exec');
diff --git a/src/exec.js b/src/exec.js
index c31b3ae..6860aee 100644
--- a/src/exec.js
+++ b/src/exec.js
@@ -17,9 +17,7 @@
     under the License.
 */
 
-/* globals Promise: true */
-
-const child_process = require('child_process');
+const child_process = require('node:child_process');
 
 /**
  * Executes the command specified.
diff --git a/src/main.js b/src/main.js
index f53e340..2756d8d 100644
--- a/src/main.js
+++ b/src/main.js
@@ -21,37 +21,37 @@ const chalk = require('chalk');
 const compression = require('compression');
 const express = require('express');
 
-module.exports = function () {
-    return new CordovaServe();
-};
-
-function CordovaServe () {
-    this.app = express();
-
-    // Attach this before anything else to provide status output
-    this.app.use((req, res, next) => {
-        res.on('finish', function () {
-            const color = this.statusCode === 404 ? chalk.red : chalk.green;
-            let msg = `${color(this.statusCode)} ${this.req.originalUrl}`;
-            const encoding = this.getHeader('content-encoding');
-            if (encoding) {
-                msg += chalk.gray(` (${encoding})`);
-            }
-            require('./server').log(msg);
+class CordovaServe {
+    constructor () {
+        this.app = express();
+
+        // Attach this before anything else to provide status output
+        this.app.use((req, res, next) => {
+            res.on('finish', function () {
+                const color = this.statusCode === 404 ? chalk.red : 
chalk.green;
+                let msg = `${color(this.statusCode)} ${this.req.originalUrl}`;
+                const encoding = this.getHeader('content-encoding');
+                if (encoding) {
+                    msg += chalk.gray(` (${encoding})`);
+                }
+                require('./server').log(msg);
+            });
+            next();
         });
-        next();
-    });
 
-    // Turn on compression
-    this.app.use(compression());
+        // Turn on compression
+        this.app.use(compression());
 
-    this.servePlatform = require('./platform');
-    this.launchServer = require('./server');
-    this.launchBrowser = require('./browser');
+        this.servePlatform = require('./platform');
+        this.launchServer = require('./server');
+        this.launchBrowser = require('./browser');
+    }
 }
 
+module.exports = function () {
+    return new CordovaServe();
+};
 module.exports.launchBrowser = require('./browser');
-
 // Expose some useful express statics
 module.exports.Router = express.Router;
 module.exports.static = express.static;
diff --git a/src/platform.js b/src/platform.js
index ffaf764..ba9ee65 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -17,9 +17,7 @@
     under the License.
 */
 
-/* globals Promise: true */
-
-const fs = require('fs');
+const fs = require('node:fs');
 const util = require('./util');
 
 /**
diff --git a/src/server.js b/src/server.js
index e4bf86a..0f0431f 100644
--- a/src/server.js
+++ b/src/server.js
@@ -17,8 +17,6 @@
     under the License.
 */
 
-/* globals Promise: true */
-
 const chalk = require('chalk');
 const express = require('express');
 
diff --git a/src/util.js b/src/util.js
index e58f292..7392181 100644
--- a/src/util.js
+++ b/src/util.js
@@ -17,8 +17,8 @@
     under the License.
 */
 
-const fs = require('fs');
-const path = require('path');
+const fs = require('node:fs');
+const path = require('node:path');
 
 // Some helpful utility stuff copied from cordova-lib. This is a bit nicer 
than taking a dependency on cordova-lib just
 // to get this minimal stuff. Hopefully we won't need the platform stuff 
(finding platform www_dir) once it is moved


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to