You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2020/06/12 15:04:37 UTC

[cordova-electron] branch master updated: refactor: cleanup unused code (#153)

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-electron.git


The following commit(s) were added to refs/heads/master by this push:
     new f2d4575  refactor: cleanup unused code (#153)
f2d4575 is described below

commit f2d4575c6217a9e0a6afe417a984f53cb773d5bd
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Sat Jun 13 00:04:28 2020 +0900

    refactor: cleanup unused code (#153)
    
    * refactor: remove unused update.js
    * refactor: remove old platform-centered run help
    * refactor: remove old platform-centered clean help
    * refactor: remove old platform-centered build help
    * refactor: delete platform-centered node_modules copy
---
 lib/build.js                       |  9 --------
 lib/clean.js                       |  5 -----
 lib/create.js                      |  5 -----
 lib/run.js                         |  7 ------
 lib/update.js                      | 24 --------------------
 tests/spec/unit/lib/build.spec.js  | 19 ----------------
 tests/spec/unit/lib/clean.spec.js  | 10 ---------
 tests/spec/unit/lib/create.spec.js | 12 ++--------
 tests/spec/unit/lib/run.spec.js    | 12 ----------
 tests/spec/unit/lib/update.spec.js | 46 --------------------------------------
 10 files changed, 2 insertions(+), 147 deletions(-)

diff --git a/lib/build.js b/lib/build.js
index c07539f..00a0fba 100644
--- a/lib/build.js
+++ b/lib/build.js
@@ -361,12 +361,3 @@ module.exports.run = (buildOptions, api) => require('./check_reqs')
     .catch(error => {
         throw error;
     });
-
-module.exports.help = (argv) => {
-    const binPath = path.relative(process.cwd(), argv.binPath);
-    console.log(`Usage: ${binPath} [flags]
-Flags:
-    '--debug': will build project in debug mode (default)
-    '--release': will build project for release
-    '--nobuild': will skip build process (useful when using run command)`);
-};
diff --git a/lib/clean.js b/lib/clean.js
index a1c802c..9bbd86f 100644
--- a/lib/clean.js
+++ b/lib/clean.js
@@ -44,8 +44,3 @@ module.exports.cleanProject = () => {
     console.log('lib/clean will soon only export a `run` command, please update to not call `cleanProject`.');
     return module.exports.run();
 };
-
-module.exports.help = (argv) => {
-    const binPath = path.relative(process.cwd(), argv.binPath);
-    console.log(`Usage: ${binPath}`);
-};
diff --git a/lib/create.js b/lib/create.js
index 3485a41..0a02df5 100644
--- a/lib/create.js
+++ b/lib/create.js
@@ -51,10 +51,5 @@ module.exports.createProject = (platform_dir, package_name, project_name, option
     // copy templates directory to the platform directory recursively
     fs.copySync(path.join(rootDir, 'bin/templates'), path.join(platform_dir), { overwrite: false });
 
-    // recreate our node_modules structure in the new project
-    if (fs.existsSync(path.join(rootDir, 'node_modules'))) {
-        fs.copySync(path.join(rootDir, 'node_modules'), path.join(platform_dir, 'cordova', 'node_modules'), { overwrite: false });
-    }
-
     return Promise.resolve();
 };
diff --git a/lib/run.js b/lib/run.js
index e3d7a9a..ee983c6 100644
--- a/lib/run.js
+++ b/lib/run.js
@@ -35,10 +35,3 @@ module.exports.run = (args = {}) => {
         process.exit(code);
     });
 };
-
-module.exports.help = (argv) => {
-    const binPath = path.relative(process.cwd(), argv.binPath);
-    console.log(`Usage: ${binPath} [flags]
-Flags:
-    '--nobuild': will skip build process (useful when using run command)`);
-};
diff --git a/lib/update.js b/lib/update.js
deleted file mode 100644
index bb58119..0000000
--- a/lib/update.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-*/
-
-module.exports.help = () => {
-    console.log('WARNING : Electron does not support updating. Remove and then re-Add the platform to get the latest.');
-};
-
-module.exports.run = () => Promise.reject(new Error('Update not supported'));
diff --git a/tests/spec/unit/lib/build.spec.js b/tests/spec/unit/lib/build.spec.js
index fa68d88..372d18d 100644
--- a/tests/spec/unit/lib/build.spec.js
+++ b/tests/spec/unit/lib/build.spec.js
@@ -1732,23 +1732,4 @@ describe('Testing build.js:', () => {
             );
         });
     });
-
-    describe('Module exports help', () => {
-        it('should display help usage.', () => {
-            const help = build.__get__('module.exports.help');
-            const argv = { binPath: 'bin' };
-
-            // create spies
-            spyOn(console, 'log');
-
-            help(argv);
-
-            expect(console.log).toHaveBeenCalled();
-
-            const actual = console.log.calls.argsFor(0)[0];
-            expect(actual).toContain('--debug');
-            expect(actual).toContain('--release');
-            expect(actual).toContain('--nobuild');
-        });
-    });
 });
diff --git a/tests/spec/unit/lib/clean.spec.js b/tests/spec/unit/lib/clean.spec.js
index 2ea5bd6..d20d13c 100644
--- a/tests/spec/unit/lib/clean.spec.js
+++ b/tests/spec/unit/lib/clean.spec.js
@@ -89,14 +89,4 @@ describe('Clean', () => {
             expect(console.log).toHaveBeenCalledWith('lib/clean will soon only export a `run` command, please update to not call `cleanProject`.');
         });
     });
-
-    describe('help export method', () => {
-        it('should console out clean usage.', () => {
-            spyOn(console, 'log');
-
-            clean.help({ binPath: 'foobar' });
-
-            expect(console.log).toHaveBeenCalledWith('Usage: foobar');
-        });
-    });
 });
diff --git a/tests/spec/unit/lib/create.spec.js b/tests/spec/unit/lib/create.spec.js
index fca94b2..4295b3f 100644
--- a/tests/spec/unit/lib/create.spec.js
+++ b/tests/spec/unit/lib/create.spec.js
@@ -26,7 +26,7 @@ const tmpDir = path.join(rootDir, 'temp');
 
 const create = rewire(path.join(rootDir, 'lib/create'));
 
-function createAndValidateProjectDirName (projectname, projectid, { copyNodeModules = false } = {}) {
+function createAndValidateProjectDirName (projectname, projectid) {
     // remove existing folder
     fs.removeSync(tmpDir);
     fs.ensureDirSync(tmpDir);
@@ -36,8 +36,7 @@ function createAndValidateProjectDirName (projectname, projectid, { copyNodeModu
     const _fs = create.__get__('fs');
     create.__set__('fs', {
         ensureDirSync: _fs.ensureDirSync,
-        existsSync: path => path !== projectPath &&
-            !(path.includes('node_modules') && copyNodeModules),
+        existsSync: path => path !== projectPath,
         copySync: () => true
     });
 
@@ -94,13 +93,6 @@ describe('create', () => {
         return createAndValidateProjectDirName(projectname, projectid);
     });
 
-    it('copy node_modules folder if it exists', () => {
-        const projectname = 'withnodemodules';
-        const projectid = 'com.test.withnodemodules';
-
-        return createAndValidateProjectDirName(projectname, projectid, { copyNodeModules: true });
-    });
-
     it('should stop creating project when project destination already exists', () => {
         const _fs = create.__get__('fs');
         create.__set__('fs', {
diff --git a/tests/spec/unit/lib/run.spec.js b/tests/spec/unit/lib/run.spec.js
index 5492c94..65b4d61 100644
--- a/tests/spec/unit/lib/run.spec.js
+++ b/tests/spec/unit/lib/run.spec.js
@@ -75,16 +75,4 @@ describe('Run', () => {
             expect(process.exit).toHaveBeenCalled();
         });
     });
-
-    describe('help export method', () => {
-        it('should console out run usage.', () => {
-            spyOn(console, 'log');
-
-            run.help({ binPath: 'foobar' });
-
-            expect(console.log.calls.argsFor(0)[0]).toContain('Usage');
-            expect(console.log.calls.argsFor(0)[0]).toContain('foobar');
-            expect(console.log.calls.argsFor(0)[0]).toContain('nobuild');
-        });
-    });
 });
diff --git a/tests/spec/unit/lib/update.spec.js b/tests/spec/unit/lib/update.spec.js
deleted file mode 100644
index b8fb0fb..0000000
--- a/tests/spec/unit/lib/update.spec.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-*/
-
-const path = require('path');
-const rewire = require('rewire');
-
-const rootDir = path.resolve(__dirname, '../../../..');
-
-const update = rewire(path.join(rootDir, 'lib/update'));
-
-describe('Update', () => {
-    describe('run export method', () => {
-        it('should reject with an errror that update is not supported.', () => {
-            update.run().then(
-                () => {},
-                error => {
-                    expect(error).toEqual(new Error('Update not supported'));
-                }
-            );
-        });
-    });
-
-    describe('help export method', () => {
-        it('should warn that updating is not support for Electron.', () => {
-            spyOn(console, 'log');
-            update.help();
-            expect(console.log).toHaveBeenCalledWith('WARNING : Electron does not support updating. Remove and then re-Add the platform to get the latest.');
-        });
-    });
-});


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