From 950abb554bade0c981d1f0afda814394de6c5f02 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 16 Apr 2020 19:42:41 +0900 Subject: [PATCH] refactor: small formatting changes --- index.js | 6 +----- spec/create.spec.js | 6 +----- spec/helpers.js | 2 +- spec/templates/withsubdirectory/index.js | 1 + spec/templates/withsubdirectory_package_json/index.js | 1 + 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index cccf159f..bdfbdb81 100644 --- a/index.js +++ b/index.js @@ -18,9 +18,7 @@ */ const fs = require('fs-extra'); - const path = require('path'); - const tmp = require('tmp'); const npa = require('npm-package-arg'); const globby = require('globby'); @@ -28,10 +26,8 @@ const isObject = require('isobject'); const pathIsInside = require('path-is-inside'); const requireFresh = require('import-fresh'); const validateIdentifier = require('valid-identifier'); - const fetch = require('cordova-fetch'); -const CordovaError = require('cordova-common').CordovaError; -const ConfigParser = require('cordova-common').ConfigParser; +const { CordovaError, ConfigParser } = require('cordova-common'); module.exports = cordovaCreate; diff --git a/spec/create.spec.js b/spec/create.spec.js index 2b72cf2c..617086ff 100644 --- a/spec/create.spec.js +++ b/spec/create.spec.js @@ -19,14 +19,10 @@ const fs = require('fs-extra'); const rewire = require('rewire'); - const path = require('path'); - const requireFresh = require('import-fresh'); - const create = require('..'); -const CordovaError = require('cordova-common').CordovaError; -const ConfigParser = require('cordova-common').ConfigParser; +const { CordovaError, ConfigParser } = require('cordova-common'); const { tmpDir, createWith, createWithMockFetch, expectRejection } = require('./helpers'); const appName = 'TestBase'; diff --git a/spec/helpers.js b/spec/helpers.js index 80d0c2b6..65275b71 100644 --- a/spec/helpers.js +++ b/spec/helpers.js @@ -20,7 +20,6 @@ const fs = require('fs-extra'); const os = require('os'); const path = require('path'); - const rewire = require('rewire'); // Temporary directory to use for all tests @@ -28,6 +27,7 @@ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cordova-create-tests-')); // Returns a version of create with its local scope rewired const create = rewire('..'); + function createWith (rewiring) { return (...args) => create.__with__(rewiring)(() => create(...args)); } diff --git a/spec/templates/withsubdirectory/index.js b/spec/templates/withsubdirectory/index.js index 3ad198a1..50e20de9 100644 --- a/spec/templates/withsubdirectory/index.js +++ b/spec/templates/withsubdirectory/index.js @@ -1,4 +1,5 @@ const path = require('path'); + module.exports = { 'dirname': path.join(__dirname, 'template') }; diff --git a/spec/templates/withsubdirectory_package_json/index.js b/spec/templates/withsubdirectory_package_json/index.js index 3ad198a1..50e20de9 100644 --- a/spec/templates/withsubdirectory_package_json/index.js +++ b/spec/templates/withsubdirectory_package_json/index.js @@ -1,4 +1,5 @@ const path = require('path'); + module.exports = { 'dirname': path.join(__dirname, 'template') };