From d34ae66306741a6e8c8e633969f97065664f5941 Mon Sep 17 00:00:00 2001 From: Vitaly Zakutny Date: Sun, 19 Nov 2023 14:58:46 +0300 Subject: [PATCH] chore: changed args for create new locale file like cp command --- src/commands/newLocale.ts | 22 +++++++--------------- src/modifiers/newLocale.ts | 12 ++++-------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/commands/newLocale.ts b/src/commands/newLocale.ts index 389d661..5f444a3 100644 --- a/src/commands/newLocale.ts +++ b/src/commands/newLocale.ts @@ -7,35 +7,27 @@ export const description = 'Create new localization file from master file'; export function builder(yargs: Argv) { return yargs - .option('name', { - alias: 'n', - desc: 'Name of new localization file', - demandOption: true, - type: 'string' - }) .option('master', { alias: 'm', desc: 'Master localization file', demandOption: true, type: 'string' }) - .option('directory', { - alias: 'dir', - desc: 'Directory of localization files', - type: 'string', - default: 'mock' + .option('name', { + alias: 'n', + desc: 'Name of new localization file', + demandOption: true, + type: 'string' }) .usage(`\nExample:\n $0 ${command} -n strings-kz.xml -m strings.xml`); } export async function handler({ name, - master, - directory + master }: ArgumentsCamelCase<{ name: string; master: string; - directory: string; }>) { - newLocale({ name, master, directory }); + newLocale({ name, master }); } diff --git a/src/modifiers/newLocale.ts b/src/modifiers/newLocale.ts index 0bea49b..631e390 100644 --- a/src/modifiers/newLocale.ts +++ b/src/modifiers/newLocale.ts @@ -1,18 +1,14 @@ import * as fs from 'fs'; -export function newLocale(options: { - name: string; - master: string; - directory: string; -}) { - const { name, master, directory } = options; +export function newLocale(options: { name: string; master: string }) { + const { name, master } = options; - fs.copyFile(`${directory}/${master}`, `${directory}/${name}`, (err) => { + fs.copyFile(master, name, (err) => { if (err) { console.error(err); return; } - console.log(`${master} was copied to ${directory}/${name}`); + console.log(`${master} was copied to ${name}`); }); }