prepare-package 1.1.3 → 1.1.4

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 (3) hide show
  1. package/dist/index.js +13 -11
  2. package/package.json +1 -1
  3. package/src/index.js +13 -11
package/dist/index.js CHANGED
@@ -40,21 +40,23 @@ module.exports = async function (options) {
40
40
  console.log(chalk.blue(`[prepare-package]: output=${theirPackageJSON.preparePackage.output}`));
41
41
  console.log(chalk.blue(`[prepare-package]: main=${theirPackageJSON.main}`));
42
42
 
43
- // Remove the output folder
44
- jetpack.remove(
45
- path.resolve(options.cwd, theirPackageJSON.preparePackage.output),
46
- )
43
+ // Set the paths relative to the cwd
44
+ const mainPath = path.resolve(options.cwd, theirPackageJSON.main);
45
+ const outputPath = path.resolve(options.cwd, theirPackageJSON.preparePackage.output);
46
+ const inputPath = path.resolve(options.cwd, theirPackageJSON.preparePackage.input);
47
+
48
+ // Remove the output folder if it exists
49
+ if (jetpack.exists(outputPath)) {
50
+ jetpack.remove(outputPath);
51
+ }
47
52
 
48
- // Copy the input folder to the output folder
49
- jetpack.copy(
50
- path.resolve(options.cwd, theirPackageJSON.preparePackage.input),
51
- path.resolve(options.cwd, theirPackageJSON.preparePackage.output),
52
- )
53
+ // Copy the input folder to the output folder if it exists
54
+ if (jetpack.exists(inputPath)) {
55
+ jetpack.copy(inputPath, outputPath);
56
+ }
53
57
 
54
58
  // Only do this part on the actual package that is using THIS package because we dont't want to replace THIS {version}
55
59
  if (isLivePreparation) {
56
- const mainPath = path.resolve(options.cwd, theirPackageJSON.main);
57
-
58
60
  // Replace the main file
59
61
  jetpack.write(
60
62
  mainPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prepare-package",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Prepare a Node.js package before being published",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -40,21 +40,23 @@ module.exports = async function (options) {
40
40
  console.log(chalk.blue(`[prepare-package]: output=${theirPackageJSON.preparePackage.output}`));
41
41
  console.log(chalk.blue(`[prepare-package]: main=${theirPackageJSON.main}`));
42
42
 
43
- // Remove the output folder
44
- jetpack.remove(
45
- path.resolve(options.cwd, theirPackageJSON.preparePackage.output),
46
- )
43
+ // Set the paths relative to the cwd
44
+ const mainPath = path.resolve(options.cwd, theirPackageJSON.main);
45
+ const outputPath = path.resolve(options.cwd, theirPackageJSON.preparePackage.output);
46
+ const inputPath = path.resolve(options.cwd, theirPackageJSON.preparePackage.input);
47
+
48
+ // Remove the output folder if it exists
49
+ if (jetpack.exists(outputPath)) {
50
+ jetpack.remove(outputPath);
51
+ }
47
52
 
48
- // Copy the input folder to the output folder
49
- jetpack.copy(
50
- path.resolve(options.cwd, theirPackageJSON.preparePackage.input),
51
- path.resolve(options.cwd, theirPackageJSON.preparePackage.output),
52
- )
53
+ // Copy the input folder to the output folder if it exists
54
+ if (jetpack.exists(inputPath)) {
55
+ jetpack.copy(inputPath, outputPath);
56
+ }
53
57
 
54
58
  // Only do this part on the actual package that is using THIS package because we dont't want to replace THIS {version}
55
59
  if (isLivePreparation) {
56
- const mainPath = path.resolve(options.cwd, theirPackageJSON.main);
57
-
58
60
  // Replace the main file
59
61
  jetpack.write(
60
62
  mainPath,