Skip to content

Commit

Permalink
Merge pull request #171 from Shopify/bugfix/copy-artifacts-fails-3
Browse files Browse the repository at this point in the history
Updated with correct copy directory.
  • Loading branch information
chrfalch authored Feb 2, 2022
2 parents e10fc2a + b219ee9 commit 11eb2a2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
30 changes: 29 additions & 1 deletion scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { exec, execSync } from "child_process";
import { exit } from "process";
const fs = require("fs");
import path from "path";
import fs from "fs";

export const executeCmdSync = (command: string) => {
try {
Expand Down Expand Up @@ -77,3 +78,30 @@ export const restoreFile = (filePathToBeRestored: string) => {
fs.unlinkSync(filePathToBeRestored);
fs.renameSync(getBackupFilename(filePathToBeRestored), filePathToBeRestored);
};

/**
* Look ma, it's cp -R.
* @param {string} src The path to the thing to copy.
* @param {string} dest The path to the new copy.
*/
export var copyRecursiveSync = function (src: string, dest: string) {
var exists = fs.existsSync(src);
if (!exists) {
return;
}
var stats = fs.statSync(src);
var isDirectory = stats.isDirectory();
if (isDirectory) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
fs.readdirSync(src).forEach((childItemName) => {
copyRecursiveSync(
path.join(src, childItemName),
path.join(dest, childItemName)
);
});
} else {
fs.copyFileSync(src, dest);
}
};
28 changes: 1 addition & 27 deletions scripts/workflow-copy-libs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from "fs";
import path from "path";
import { ensureFolderExists } from "./utils";
import { ensureFolderExists, copyRecursiveSync } from "./utils";
/**
* This build script prepares the npm build command by copying
* the Skia Binaries from the artifact folder into the libs folder
Expand Down Expand Up @@ -63,28 +62,3 @@ console.log("Copying ios files...");
copyFiles("skia-ios-xcframeworks", "./package/libs/ios", iosFiles);

console.log("Done copying artifacts.");

/**
* Look ma, it's cp -R.
* @param {string} src The path to the thing to copy.
* @param {string} dest The path to the new copy.
*/
var copyRecursiveSync = function (src: string, dest: string) {
var exists = fs.existsSync(src);
if (!exists) {
return;
}
var stats = fs.statSync(src);
var isDirectory = stats.isDirectory();
if (isDirectory) {
fs.mkdirSync(dest);
fs.readdirSync(src).forEach(function (childItemName) {
copyRecursiveSync(
path.join(src, childItemName),
path.join(dest, childItemName)
);
});
} else {
fs.copyFileSync(src, dest);
}
};

0 comments on commit 11eb2a2

Please sign in to comment.