sfxmix 1.2.0 → 1.2.2

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.
Files changed (2) hide show
  1. package/index.js +22 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -103,12 +103,32 @@ class SfxMix {
103
103
  }
104
104
  }
105
105
  // Finalize output
106
- fs.renameSync(this.currentFile, output);
106
+ const absoluteOutput = path.resolve(process.cwd(), output);
107
+ const outputDir = path.dirname(absoluteOutput);
108
+
109
+ // Ensure the output directory exists
110
+ if (!fs.existsSync(outputDir)) {
111
+ fs.mkdirSync(outputDir, { recursive: true });
112
+ }
113
+
114
+ // Check if the source file exists
115
+ if (!fs.existsSync(this.currentFile)) {
116
+ throw new Error(`Source file does not exist: ${this.currentFile}`);
117
+ }
118
+
119
+ // Attempt to rename the file
120
+ try {
121
+ fs.renameSync(this.currentFile, absoluteOutput);
122
+ } catch (renameErr) {
123
+ // If rename fails, try to copy the file instead
124
+ fs.copyFileSync(this.currentFile, absoluteOutput);
125
+ fs.unlinkSync(this.currentFile);
126
+ }
107
127
 
108
128
  // Reset internal state
109
129
  this.reset();
110
130
 
111
- resolve(output);
131
+ resolve(absoluteOutput);
112
132
  } catch (err) {
113
133
  console.error('Error during audio processing:', err);
114
134
  reject(err);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sfxmix",
3
3
  "description": "🎧 SfxMix - Powerful and easy-to-use module for processing audio.",
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "fluent-ffmpeg": "^2.1.3",