File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import chalk from 'chalk'
22import dotenv from 'dotenv'
3- import { isFileDir } from '@resultify/hubspot-tools-theme-lib/lib /utils/fs.js'
3+ import { isFileDir } from '.. /utils/fs.js'
44
55/**
66 * @summary Get .env config
Original file line number Diff line number Diff line change 1- import { checkNode } from '@resultify/hubspot-tools-theme -lib/lib/utils/check.js'
1+ // import { checkNode } from '@resultify/hubspot-cms -lib/lib/utils/check.js'
22import { parseArgs , checkIfMoreThanOneArg } from './arg/arg.js'
33import { localstorage } from './local-storage.js'
44import { showInfo as info } from './cmd/info.js'
@@ -10,7 +10,7 @@ await checkIfSsh()
1010await checkIfBinExists ( 'git' )
1111await checkIfBinExists ( 'node' )
1212await checkIfBinExists ( 'npm' )
13- checkNode ( )
13+ // checkNode()
1414
1515// cli data localstorage
1616let data = await localstorage ( )
Original file line number Diff line number Diff line change 11import { execa } from 'execa'
2- import { isFileDir } from '@resultify/hubspot-tools-theme-lib/lib/utils/fs.js'
3- import { createRequire } from 'module'
4- const require = createRequire ( import . meta. url )
5-
6- /**
7- * @summary Import theme.json
8- * @async
9- * @private
10- * @returns {Promise<Object|boolean> } theme.json|false
11- */
12- async function importThemeJson ( ) {
13- if ( await isFileDir ( `${ process . cwd ( ) } /theme/theme.json` ) ) {
14- return require ( `${ process . cwd ( ) } /theme/theme.json` )
15- } else {
16- return false
17- }
18- }
19-
20- /**
21- * @summary Import package.json
22- * @async
23- * @private
24- * @returns {Promise<Object|boolean> } package.json|false
25- */
26- async function importPackageJson ( ) {
27- if ( await isFileDir ( `${ process . cwd ( ) } /package.json` ) ) {
28- return require ( `${ process . cwd ( ) } /package.json` )
29- } else {
30- return false
31- }
32- }
2+ import { importThemeJson , importPackageJson } from './utils/fs.js'
333
344/**
355 * @summary data locals torage
Original file line number Diff line number Diff line change 1+ import fsPromises from 'fs/promises'
2+ import { createRequire } from 'module'
3+ const require = createRequire ( import . meta. url )
4+
5+ /**
6+ * @summary check if file/dir exists
7+ * @async
8+ * @param {string } path - file/dir path
9+ * @returns {Promise<boolean> }
10+ */
11+ async function isFileDir ( path ) {
12+ try {
13+ await fsPromises . stat ( path )
14+ return true
15+ } catch ( error ) {
16+ if ( error . code === 'ENOENT' ) {
17+ return false
18+ }
19+ console . error ( error )
20+ }
21+ }
22+
23+ /**
24+ * @summary Import theme.json
25+ * @async
26+ * @private
27+ * @returns {Promise<Object|boolean> } theme.json|false
28+ */
29+ async function importThemeJson ( ) {
30+ if ( await isFileDir ( `${ process . cwd ( ) } /theme/theme.json` ) ) {
31+ return require ( `${ process . cwd ( ) } /theme/theme.json` )
32+ } else {
33+ return false
34+ }
35+ }
36+
37+ /**
38+ * @summary Import package.json
39+ * @async
40+ * @private
41+ * @returns {Promise<Object|boolean> } package.json|false
42+ */
43+ async function importPackageJson ( ) {
44+ if ( await isFileDir ( `${ process . cwd ( ) } /package.json` ) ) {
45+ return require ( `${ process . cwd ( ) } /package.json` )
46+ } else {
47+ return false
48+ }
49+ }
50+
51+ export { importPackageJson , importThemeJson , isFileDir }
You can’t perform that action at this time.
0 commit comments