Bring back copySync (#135)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-03-16 01:36:23 +01:00 committed by GitHub
parent c6b59a0018
commit e64e818e83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 3252 additions and 267 deletions

3368
dist/index.js generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -23,10 +23,12 @@
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"addressparser": "^1.0.1" "addressparser": "^1.0.1",
"fs-extra": "^9.0.1"
}, },
"devDependencies": { "devDependencies": {
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@types/fs-extra": "^9.0.1",
"@types/node": "^14.11.2", "@types/node": "^14.11.2",
"@vercel/ncc": "^0.24.1", "@vercel/ncc": "^0.24.1",
"prettier": "^2.1.2", "prettier": "^2.1.2",

View File

@ -1,10 +1,10 @@
import addressparser from 'addressparser'; import addressparser from 'addressparser';
import {copySync} from 'fs-extra';
import * as fs from 'fs'; import * as fs from 'fs';
import * as os from 'os'; import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as git from './git'; import * as git from './git';
import * as util from './util';
async function run() { async function run() {
try { try {
@ -57,8 +57,11 @@ async function run() {
await git.checkout(targetBranch); await git.checkout(targetBranch);
} }
await core.group(`🏃 Copying ${path.join(currentdir, buildDir)} contents to ${tmpdir}`, async () => { core.info(`🏃 Copying ${path.join(currentdir, buildDir)} contents to ${tmpdir}`);
await util.copyDir(path.join(currentdir, buildDir), tmpdir); await copySync(path.join(currentdir, buildDir), tmpdir, {
overwrite: true,
errorOnExist: false,
dereference: true
}); });
if (fqdn) { if (fqdn) {

View File

@ -1,77 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
import * as core from '@actions/core';
export async function copyDir(from: string, to: string): Promise<void> {
core.debug(`copyDir ${from} to ${to}`);
await fs.promises.mkdir(to, {recursive: true}).catch(err => {
core.warning(err);
});
core.debug(`readdir ${from}`);
await fs.promises.readdir(from).then(async (files: string[]) => {
for (let fname of files) {
core.debug(`# ${fname}`);
core.debug(`stat ${path.join(from, fname)}`);
const stat = await fs.promises.lstat(path.join(from, fname));
if (stat.isFile()) {
core.debug(`stat.isFile`);
await fs.promises
.copyFile(path.join(from, fname), path.join(to, fname))
.then(_ => {
core.info(
`${path.join(from, fname).replace(process.env.GITHUB_WORKSPACE || '', '.')} => ${path.join(to, fname)}`
);
})
.catch(err => {
core.warning(err);
});
} else if (stat.isSymbolicLink()) {
core.debug(`stat.isSymbolicLink`);
await copySymlink(path.join(from, fname), path.join(to, fname));
} else if (stat.isDirectory()) {
core.debug(`stat.isDirectory`);
await copyDir(path.join(from, fname), path.join(to, fname));
}
}
});
}
async function copySymlink(from: string, to: string): Promise<void> {
core.debug(`copySymlink ${from} to ${to}`);
const llink = await fs.promises.readlink(from).catch(err => {
if (err) {
core.warning(err);
}
});
core.debug(`llink ${llink}`);
if (!llink) {
return;
}
const lsrc = path.resolve(llink);
core.debug(`lsrc ${lsrc}`);
const lstat = await fs.promises.lstat(llink).catch(err => {
if (err) {
core.warning(`Cannot stat symlink ${llink} for ${from.replace(process.env.GITHUB_WORKSPACE || '', '.')}: ${err}`);
}
});
if (!lstat) {
return;
}
if (lstat.isFile()) {
core.debug(`lstat.isFile`);
await fs.promises
.copyFile(lsrc, to)
.then(_ => {
core.info(`${lsrc.replace(process.env.GITHUB_WORKSPACE || '', '.')} => ${to}`);
})
.catch(err => {
core.warning(err);
});
} else if (lstat.isSymbolicLink()) {
core.debug(`lstat.isSymbolicLink`);
await copySymlink(lsrc, to);
} else if (lstat.isDirectory()) {
core.debug(`lstat.isDirectory`);
await copyDir(lsrc, to);
}
}

View File

@ -19,10 +19,17 @@
resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.0.2.tgz#2f614b6e69ce14d191180451eb38e6576a6e6b27" resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.0.2.tgz#2f614b6e69ce14d191180451eb38e6576a6e6b27"
integrity sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg== integrity sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg==
"@types/node@^14.11.2": "@types/fs-extra@^9.0.1":
version "14.11.2" version "9.0.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.2.tgz#2de1ed6670439387da1c9f549a2ade2b0a799256" resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.8.tgz#32c3c07ddf8caa5020f84b5f65a48470519f78ba"
integrity sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA== integrity sha512-bnlTVTwq03Na7DpWxFJ1dvnORob+Otb8xHyUqUWhqvz/Ksg8+JXPlR52oeMSZ37YEOa5PyccbgUNutiQdi13TA==
dependencies:
"@types/node" "*"
"@types/node@*", "@types/node@^14.11.2":
version "14.14.35"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.35.tgz#42c953a4e2b18ab931f72477e7012172f4ffa313"
integrity sha512-Lt+wj8NVPx0zUmUwumiVXapmaLUcAk3yPuHCFVXras9k5VT9TdhJqKqGVUQCD60OTMCl0qxJ57OiTL0Mic3Iag==
"@vercel/ncc@^0.24.1": "@vercel/ncc@^0.24.1":
version "0.24.1" version "0.24.1"
@ -34,6 +41,11 @@ addressparser@^1.0.1:
resolved "https://registry.yarnpkg.com/addressparser/-/addressparser-1.0.1.tgz#47afbe1a2a9262191db6838e4fd1d39b40821746" resolved "https://registry.yarnpkg.com/addressparser/-/addressparser-1.0.1.tgz#47afbe1a2a9262191db6838e4fd1d39b40821746"
integrity sha1-R6++GiqSYhkdtoOOT9HTm0CCF0Y= integrity sha1-R6++GiqSYhkdtoOOT9HTm0CCF0Y=
at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
commander@^2.19.0: commander@^2.19.0:
version "2.20.3" version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
@ -54,6 +66,30 @@ editorconfig@^0.15.0:
semver "^5.6.0" semver "^5.6.0"
sigmund "^1.0.1" sigmund "^1.0.1"
fs-extra@^9.0.1:
version "9.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
dependencies:
at-least-node "^1.0.0"
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
version "4.2.6"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee"
integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==
jsonfile@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
dependencies:
universalify "^2.0.0"
optionalDependencies:
graceful-fs "^4.1.6"
lru-cache@^4.1.5: lru-cache@^4.1.5:
version "4.1.5" version "4.1.5"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
@ -63,9 +99,9 @@ lru-cache@^4.1.5:
yallist "^2.1.2" yallist "^2.1.2"
prettier@^2.1.2: prettier@^2.1.2:
version "2.1.2" version "2.2.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg== integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==
pseudomap@^1.0.2: pseudomap@^1.0.2:
version "1.0.2" version "1.0.2"
@ -91,9 +127,14 @@ typescript-formatter@^7.2.2:
editorconfig "^0.15.0" editorconfig "^0.15.0"
typescript@^4.0.3: typescript@^4.0.3:
version "4.0.3" version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg== integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
yallist@^2.1.2: yallist@^2.1.2:
version "2.1.2" version "2.1.2"