Skip to content

Commit

Permalink
chore(cli): fix unused warnings (#3625)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Sep 29, 2020
1 parent 0248fd1 commit d5b1631
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 50 deletions.
5 changes: 2 additions & 3 deletions cli/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import xml2js from 'xml2js';
import c from './colors';
import type { Config, PackageJson, ExternalConfig } from './definitions';
import { output, logger } from './log';
import { emoji as _e } from './util/emoji';
import { copyAsync, existsAsync, readFileAsync, renameAsync } from './util/fs';

export type CheckFunction = () => Promise<string | null>;
Expand Down Expand Up @@ -60,7 +59,7 @@ export async function checkWebDir(config: Config): Promise<string | null> {
return null;
}

export async function checkPackage(_config: Config): Promise<string | null> {
export async function checkPackage(): Promise<string | null> {
if (!(await existsAsync('package.json'))) {
return (
`The Capacitor CLI needs to run at the root of an npm package.\n` +
Expand Down Expand Up @@ -185,7 +184,7 @@ export function parseXML(xmlStr: string): any {
}

export async function writeXML(object: any): Promise<any> {
return new Promise((resolve, reject) => {
return new Promise(resolve => {
const builder = new xml2js.Builder({
headless: true,
explicitRoot: false,
Expand Down
6 changes: 3 additions & 3 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function run(): Promise<void> {
.command('create [directory] [name] [id]', { hidden: true })
.description('Creates a new Capacitor project')
.action(() => {
return createCommand(config);
return createCommand();
});

program
Expand All @@ -48,7 +48,7 @@ export async function run(): Promise<void> {
.command('serve', { hidden: true })
.description('Serves a Capacitor Progressive Web App in the browser')
.action(() => {
return serveCommand(config);
return serveCommand();
});

program
Expand Down Expand Up @@ -114,7 +114,7 @@ export async function run(): Promise<void> {
.command('plugin:generate', { hidden: true })
.description('start a new Capacitor plugin')
.action(() => {
return newPluginCommand(config);
return newPluginCommand();
});

program.arguments('[command]').action(cmd => {
Expand Down
2 changes: 0 additions & 2 deletions cli/src/ios/add.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { relative } from 'path';

import c from '../colors';
import { copyTemplate, runTask } from '../common';
import type { Config } from '../definitions';
Expand Down
2 changes: 1 addition & 1 deletion cli/src/tasks/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function addCommand(

try {
await check([
() => checkPackage(config),
() => checkPackage(),
() => checkAppConfig(config),
...addChecks(config, platformName),
]);
Expand Down
3 changes: 1 addition & 2 deletions cli/src/tasks/create.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import c from '../colors';
import { logFatal } from '../common';
import type { Config } from '../definitions';

export async function createCommand(config: Config): Promise<void> {
export async function createCommand(): Promise<void> {
logFatal(
`The create command has been removed.\n` +
`Use ${c.input('npm init @capacitor/app')}`,
Expand Down
1 change: 0 additions & 1 deletion cli/src/tasks/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { getCordovaPreferences } from '../cordova';
import type { Config } from '../definitions';
import { output } from '../log';
import { emoji as _e } from '../util/emoji';
import { checkInteractive, isInteractive } from '../util/term';

export async function initCommand(
Expand Down
3 changes: 1 addition & 2 deletions cli/src/tasks/new-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import c from '../colors';
import { logFatal } from '../common';
import type { Config } from '../definitions';

export async function newPluginCommand(config: Config): Promise<void> {
export async function newPluginCommand(): Promise<void> {
logFatal(
`The plugin:generate command has been removed.\n` +
`Use ${c.input('npm init @capacitor/plugin')}`,
Expand Down
3 changes: 1 addition & 2 deletions cli/src/tasks/serve.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import c from '../colors';
import { logFatal } from '../common';
import type { Config } from '../definitions';

export async function serveCommand(config: Config): Promise<void> {
export async function serveCommand(): Promise<void> {
logFatal(
`The serve command has been removed.\n` +
`Use a third-party tool for serving single page apps, such as ${c.strong(
Expand Down
2 changes: 1 addition & 1 deletion cli/src/tasks/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function syncCommand(
}
try {
await check([
() => checkPackage(config),
() => checkPackage(),
() => checkWebDir(config),
...updateChecks(config, platforms),
]);
Expand Down
5 changes: 1 addition & 4 deletions cli/src/tasks/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ export async function updateCommand(
return;
}
try {
await check([
() => checkPackage(config),
...updateChecks(config, platforms),
]);
await check([() => checkPackage(), ...updateChecks(config, platforms)]);

await allSerial(
platforms.map(platformName => async () =>
Expand Down
2 changes: 1 addition & 1 deletion cli/src/util/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const readFileSync = fsExtra.readFileSync;
export const writeFileSync = fsExtra.writeFileSync;
export const existsAsync = async (path: string): Promise<boolean> => {
try {
const stat = await statAsync(path);
await statAsync(path);
return true;
} catch {
return false;
Expand Down
28 changes: 0 additions & 28 deletions cli/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,34 +189,6 @@ const CORDOVA_PLUGIN_PACKAGE = `
}
`;

const CORDOVA_PLUGINS_RESOURCES_PODSPEC = `
Pod::Spec.new do |s|
s.name = 'CordovaPluginsResources'
s.version = '0.0.105'
s.summary = 'Resources for Cordova plugins'
s.social_media_url = 'https://twitter.com/capacitorjs'
s.license = 'MIT'
s.homepage = 'https://capacitorjs.com/'
s.authors = { 'Ionic Team' => '[email protected]' }
s.source = { :git => 'https://github.com/ionic-team/capacitor.git', :tag => s.version.to_s }
s.resources = ['resources/*']
end
`;

const CORDOVA_PLUGINS_PODSPEC = `
Pod::Spec.new do |s|
s.name = 'CordovaPlugins'
s.version = '0.0.105'
s.summary = 'Autogenerated spec'
s.license = 'Unknown'
s.homepage = 'https://example.com'
s.authors = { 'Capacitor Generator' => '[email protected]' }
s.source = { :git => 'https://github.com/ionic-team/does-not-exist.git', :tag => s.version.to_s }
s.source_files = 'sources/**/*.{swift,h,m,c,cc,mm}'
s.ios.deployment_target = '10'
s.dependency 'CapacitorCordova'
end`;

async function makeCordovaPlugin(cordovaPluginPath: string) {
const iosPath = join(cordovaPluginPath, 'src', 'ios');
const androidPath = join(cordovaPluginPath, 'android/com/getcapacitor');
Expand Down

0 comments on commit d5b1631

Please sign in to comment.