@shoper/cli 0.9.4-5 → 0.9.4-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,18 @@ export class ThemeFilesUtils {
18
18
  }
19
19
  static async writeThemeFilesStructure(themeDirectory, filesStructure) {
20
20
  const filePath = join(themeDirectory, SHOPER_THEME_METADATA_DIR, THEME_FILES_STRUCTURE_FILE_NAME);
21
- await writeJSONFile(filePath, filesStructure);
21
+ const normalizedStructure = {};
22
+ for (const [key, value] of Object.entries(filesStructure)) {
23
+ let unixKey = toUnixPath(key);
24
+ if (!unixKey.endsWith('/')) {
25
+ const fullPath = join(themeDirectory, unixKey);
26
+ if ((await fileExists(fullPath)) && (await isDirectory(fullPath))) {
27
+ unixKey = `${unixKey}/`;
28
+ }
29
+ }
30
+ normalizedStructure[unixKey] = value;
31
+ }
32
+ await writeJSONFile(filePath, normalizedStructure);
22
33
  }
23
34
  static async getFilesPermissions(themeDirectory) {
24
35
  const fileStructure = await ThemeFilesUtils.getThemeFilesStructure(themeDirectory);
@@ -21,22 +21,31 @@ export const hasParentDirectory = (path) => {
21
21
  };
22
22
  export const looksLikeDirectory = (path) => {
23
23
  const normalized = normalize(path);
24
- if (normalized.endsWith(sep))
24
+ if (normalized.endsWith(sep) || path.endsWith('/') || path.endsWith('\\'))
25
25
  return true;
26
26
  const base = basename(normalized);
27
27
  const isHidden = base.startsWith('.') && !base.slice(1).includes('.');
28
28
  const hasExtension = base.slice(1).includes('.');
29
29
  if (isHidden) {
30
- const stat = fs.lstatSync(path);
31
- return stat.isDirectory();
30
+ try {
31
+ const stat = fs.lstatSync(normalized);
32
+ return stat.isDirectory();
33
+ }
34
+ catch {
35
+ return false;
36
+ }
32
37
  }
33
38
  return isHidden || !hasExtension;
34
39
  };
35
40
  export const toUnixPath = (filePath) => {
36
- return normalize(filePath).split(sep).join(path.posix.sep);
41
+ const endsWithSep = filePath.endsWith('/') || filePath.endsWith('\\');
42
+ const result = normalize(filePath).split(sep).join(path.posix.sep);
43
+ return endsWithSep && !result.endsWith('/') ? `${result}/` : result;
37
44
  };
38
45
  export const toWinowsPath = (filePath) => {
39
- return normalize(filePath).split(sep).join(path.win32.sep);
46
+ const endsWithSep = filePath.endsWith('/') || filePath.endsWith('\\');
47
+ const result = normalize(filePath).split(sep).join(path.win32.sep);
48
+ return endsWithSep && !result.endsWith('\\') ? `${result}\\` : result;
40
49
  };
41
50
  export const isUnixPath = (path) => {
42
51
  return !path.includes('\\') && (path.startsWith('/') || path.includes('/'));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@shoper/cli",
3
3
  "packageManager": "yarn@3.2.0",
4
4
  "sideEffects": false,
5
- "version": "0.9.4-5",
5
+ "version": "0.9.4-7",
6
6
  "description": "CLI tool for Shoper",
7
7
  "author": "Joanna Firek",
8
8
  "license": "MIT",