File tree Expand file tree Collapse file tree 3 files changed +22
-18
lines changed
Expand file tree Collapse file tree 3 files changed +22
-18
lines changed Original file line number Diff line number Diff line change 88
99import { Args , Command , Flags } from '@oclif/core'
1010import Listr from 'listr'
11- import { readFileSync } from 'node:fs'
1211import { writeFile } from 'node:fs/promises'
1312import { join } from 'node:path'
1413import sharp from 'sharp'
1514import { cyan , green , red } from 'yoctocolors'
1615
16+ import { extractAppName } from '../utils/app.utils.js'
1717import { checkAssetFile , mkdirp } from '../utils/file-utils.js'
1818
1919interface ContentJsonImage {
@@ -105,14 +105,7 @@ The base icon file should be at least 1024x1024px.
105105 static override flags = {
106106 appName : Flags . string ( {
107107 char : 'a' ,
108- default ( ) {
109- try {
110- const { name } = JSON . parse ( readFileSync ( './app.json' , 'utf8' ) )
111- return name
112- } catch {
113- return null
114- }
115- } ,
108+ default : extractAppName ,
116109 description : "the appName used to build output assets path. Default is retrieved from 'app.json' file." ,
117110 } ) ,
118111 help : Flags . help ( { char : 'h' } ) ,
Original file line number Diff line number Diff line change 88
99import { Args , Command , Flags } from '@oclif/core'
1010import Listr from 'listr'
11- import { readFileSync } from 'node:fs'
1211import { writeFile } from 'node:fs/promises'
1312import { join } from 'node:path'
1413import sharp from 'sharp'
1514import { cyan , green , red } from 'yoctocolors'
1615
16+ import { extractAppName } from '../utils/app.utils.js'
1717import { checkAssetFile , mkdirp } from '../utils/file-utils.js'
1818
1919interface ContentJsonImage {
@@ -97,14 +97,7 @@ The base splashscreen file should be at least 1242x2208px.
9797 static override flags = {
9898 appName : Flags . string ( {
9999 char : 'a' ,
100- default ( ) {
101- try {
102- const { name } = JSON . parse ( readFileSync ( './app.json' , 'utf8' ) )
103- return name
104- } catch {
105- return null
106- }
107- } ,
100+ default : extractAppName ,
108101 description : "the appName used to build output assets path. Default is retrieved from 'app.json' file." ,
109102 } ) ,
110103 help : Flags . help ( { char : 'h' } ) ,
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2025 ForWarD Software (https://forwardsoftware.solutions/)
3+ *
4+ * This Source Code Form is subject to the terms of the Mozilla Public
5+ * License, v. 2.0. If a copy of the MPL was not distributed with this
6+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+ */
8+
9+ import { readFileSync } from 'node:fs'
10+
11+ export function extractAppName ( ) {
12+ try {
13+ const { name } = JSON . parse ( readFileSync ( './app.json' , 'utf8' ) )
14+ return name
15+ } catch {
16+ return null
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments