opentwig 1.0.2 → 1.0.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opentwig",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "opentwig 🌿 is an open source link in bio page generator.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -6,11 +6,18 @@ const postcss = require('postcss');
6
6
  const minify = require('postcss-minify');
7
7
 
8
8
  module.exports = async function(config) {
9
- // Check if the theme has a style.css file
10
- const cssPath = path.join(cwd, 'theme', config.theme, 'style.css');
11
-
12
- const hasCss = fs.existsSync(cssPath);
13
- if (!hasCss) {
9
+ // Try package directory first (for NPX), then current directory (for local dev)
10
+ const packageDir = path.dirname(require.main.filename);
11
+ const currentDir = process.cwd();
12
+
13
+ const cssPaths = [
14
+ path.join(packageDir, '..', 'theme', config.theme, 'style.css'), // NPX package
15
+ path.join(currentDir, 'theme', config.theme, 'style.css') // Local development
16
+ ];
17
+
18
+ const cssPath = cssPaths.find(p => fs.existsSync(p));
19
+
20
+ if (!cssPath) {
14
21
  return null;
15
22
  }
16
23
 
@@ -9,8 +9,8 @@ module.exports = function(filePath) {
9
9
 
10
10
  const absolutePath = path.join(cwd, filePath);
11
11
  if (!fs.existsSync(absolutePath)) {
12
- console.error(`File not found: ${absolutePath}`);
13
- process.exit(1);
12
+ console.warn(`Avatar file not found: ${absolutePath}. Continuing without avatar.`);
13
+ return '';
14
14
  }
15
15
 
16
16
  const extension = path.extname(absolutePath).toLowerCase();
@@ -17,7 +17,7 @@ module.exports = function(html, css, avatar,ogImage, qrImage) {
17
17
  fs.writeFileSync(path.join(distDir, 'style.css'), css);
18
18
  }
19
19
 
20
- if (avatar && avatar.path) {
20
+ if (avatar && avatar.path && fs.existsSync(path.join(cwd, avatar.path))) {
21
21
  // Get the original file extension from the avatar path
22
22
  const originalExtension = path.extname(avatar.path);
23
23
  const avatarFileName = `avatar${originalExtension}`;