mirror of
https://github.com/pnpm/action-setup
synced 2026-11-08 13:27:56 +01:00
Use glob
This commit is contained in:
1 parent
905bfaca2c
commit
cf0395bd79
3 files changed
+26
-10
No files matched your search
Vendored
+1
-1
@@ -1 +1 @@
|
||||
module.exports=function(e,i){"use strict";var n={};function __webpack_require__(i){if(n[i]){return n[i].exports}var t=n[i]={i:i,l:false,exports:{}};e[i].call(t.exports,t,t.exports,__webpack_require__);t.l=true;return t.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(803)}return startup()}({0:function(e,i){"use strict";Object.defineProperty(i,"__esModule",{value:true});i.ref="301414cec74a2b6b63c95b42f2ad1790ccb980ed";i.url=`https://raw.githubusercontent.com/pnpm/self-installer/${i.ref}/install.js`;i.default=i.url},1:function(e){"use strict";class CancelError extends Error{constructor(){super("Promise was canceled");this.name="CancelError"}get isCanceled(){return true}}class PCancelable{static fn(e){return function(){const i=[].slice.apply(arguments);return new PCancelable((n,t,a)=>{i.push(a);e.apply(null,i).then(n,t)})}}constructor(e){this._cancelHandlers=[];this._isPending=true;this._isCanceled=false;this._promise=new Promise((i,n)=>{this._reject=n;return e(e=>{this._isPending=false;i(e)},e=>{this._isPending=false;n(e)},e=>{this._cancelHandlers.push(e)})})}then(e,i){return this._promise.then(e,i)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(){if(!this._isPending||this._isCanceled){return}if(this._cancelHandlers.length>0){try{for(const e of this._cancelHandlers){e()}}catch(e){this._reject(e)}}this._isCanceled=true;this._reject(new CancelError)}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(PCancelable.prototype,Promise.prototype);e.exports=PCancelable;e.exports.CancelError=CancelError},2:function(e,i,n){"use strict";const t=n(747);const a=n(622);const r=n(210);const o={mode:511&~process.umask(),fs:t};const s=e=>{if(process.platform==="win32"){const i=/[<>:"|?*]/.test(e.replace(a.parse(e).root,""));if(i){const i=new Error(`Path contains invalid characters: ${e}`);i.code="EINVAL";throw i}}};e.exports=((e,i)=>Promise.resolve().then(()=>{s(e);i=Object.assign({},o,i);const n=r(i.fs.mkdir);const t=r(i.fs.stat);const c=e=>{return n(e,i.mode).then(()=>e).catch(i=>{if(i.code==="ENOENT"){if(i.message.includes("null bytes")||a.dirname(e)===e){throw i}return c(a.dirname(e)).then(()=>c(e))}return t(e).then(i=>i.isDirectory()?e:Promise.reject()).catch(()=>{throw i})})};return c(a.resolve(e))}));e.exports.sync=((e,i)=>{s(e);i=Object.assign({},o,i);const n=e=>{try{i.fs.mkdirSync(e,i.mode)}catch(t){if(t.code==="ENOENT"){if(t.message.includes("null bytes")||a.dirname(e)===e){throw t}n(a.dirname(e));return n(e)}try{if(!i.fs.statSync(e).isDirectory()){throw new Error("The path is not a directory")}}catch(e){throw t}}return e};return n(a.resolve(e))})},3:function(e,i,n){var t=n(669);var a=n(45);var r=n(791);var o=n(286);var s=n(441).Writable;var c=n(441).PassThrough;var p=function(){};var l=function(e){e&=511;return e&&512-e};var u=function(e,i){var n=new d(e,i);n.end();return n};var f=function(e,i){if(i.path)e.name=i.path;if(i.linkpath)e.linkname=i.linkpath;if(i.size)e.size=parseInt(i.size,10);e.pax=i;return e};var d=function(e,i){this._parent=e;this.offset=i;c.call(this)};t.inherits(d,c);d.prototype.destroy=function(e){this._parent.destroy(e)};var m=function(e){if(!(this instanceof m))return new m(e);s.call(this,e);e=e||{};this._offset=0;this._buffer=a();this._missing=0;this._partial=false;this._onparse=p;this._header=null;this._stream=null;this._overflow=null;this._cb=null;this._locked=false;this._destroyed=false;this._pax=null;this._paxGlobal=null;this._gnuLongPath=null;this._gnuLongLinkPath=null;var i=this;var n=i._buffer;var t=function(){i._continue()};var c=function(e){i._locked=false;if(e)return i.destroy(e);if(!i._stream)t()};var h=function(){i._stream=null;var e=l(i._header.size);if(e)i._parse(e,x);else i._parse(512,w);if(!i._locked)t()};var x=function(){i._buffer.consume(l(i._header.size));i._parse(512,w);t()};var v=function(){var e=i._header.size;i._paxGlobal=o.decodePax(n.slice(0,e));n.consume(e);h()};var b=function(){var e=i._header.size;i._pax=o.decodePax(n.slice(0,e));if(i._paxGlobal)i._pax=r(i._paxGlobal,i._pax);n.consume(e);h()};var g=function(){var t=i._header.size;this._gnuLongPath=o.decodeLongPath(n.slice(0,t),e.filenameEncoding);n.consume(t);h()};var y=function(){var t=i._header.size;this._gnuLongLinkPath=o.decodeLongPath(n.slice(0,t),e.filenameEncoding);n.consume(t);h()};var w=function(){var a=i._offset;var r;try{r=i._header=o.decode(n.slice(0,512),e.filenameEncoding)}catch(e){i.emit("error",e)}n.consume(512);if(!r){i._parse(512,w);t();return}if(r.type==="gnu-long-path"){i._parse(r.size,g);t();return}if(r.type==="gnu-long-link-path"){i._parse(r.size,y);t();return}if(r.type==="pax-global-header"){i._parse(r.size,v);t();return}if(r.type==="pax-header"){i._parse(r.size,b);t();return}if(i._gnuLongPath){r.name=i._gnuLongPath;i._gnuLongPath=null}if(i._gnuLongLinkPath){r.linkname=i._gnuLongLinkPath;i._gnuLongLinkPath=null}if(i._pax){i._header=r=f(r,i._pax);i._pax=null}i._locked=true;if(!r.size||r.type==="direcLine truncated
|
||||
module.exports=function(e,i){"use strict";var t={};function __webpack_require__(i){if(t[i]){return t[i].exports}var n=t[i]={i:i,l:false,exports:{}};e[i].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(803)}return startup()}({0:function(e,i){"use strict";Object.defineProperty(i,"__esModule",{value:true});i.ref="301414cec74a2b6b63c95b42f2ad1790ccb980ed";i.url=`https://raw.githubusercontent.com/pnpm/self-installer/${i.ref}/install.js`;i.default=i.url},1:function(e){"use strict";class CancelError extends Error{constructor(){super("Promise was canceled");this.name="CancelError"}get isCanceled(){return true}}class PCancelable{static fn(e){return function(){const i=[].slice.apply(arguments);return new PCancelable((t,n,a)=>{i.push(a);e.apply(null,i).then(t,n)})}}constructor(e){this._cancelHandlers=[];this._isPending=true;this._isCanceled=false;this._promise=new Promise((i,t)=>{this._reject=t;return e(e=>{this._isPending=false;i(e)},e=>{this._isPending=false;t(e)},e=>{this._cancelHandlers.push(e)})})}then(e,i){return this._promise.then(e,i)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(){if(!this._isPending||this._isCanceled){return}if(this._cancelHandlers.length>0){try{for(const e of this._cancelHandlers){e()}}catch(e){this._reject(e)}}this._isCanceled=true;this._reject(new CancelError)}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(PCancelable.prototype,Promise.prototype);e.exports=PCancelable;e.exports.CancelError=CancelError},2:function(e,i,t){"use strict";const n=t(747);const a=t(622);const r=t(210);const o={mode:511&~process.umask(),fs:n};const s=e=>{if(process.platform==="win32"){const i=/[<>:"|?*]/.test(e.replace(a.parse(e).root,""));if(i){const i=new Error(`Path contains invalid characters: ${e}`);i.code="EINVAL";throw i}}};e.exports=((e,i)=>Promise.resolve().then(()=>{s(e);i=Object.assign({},o,i);const t=r(i.fs.mkdir);const n=r(i.fs.stat);const c=e=>{return t(e,i.mode).then(()=>e).catch(i=>{if(i.code==="ENOENT"){if(i.message.includes("null bytes")||a.dirname(e)===e){throw i}return c(a.dirname(e)).then(()=>c(e))}return n(e).then(i=>i.isDirectory()?e:Promise.reject()).catch(()=>{throw i})})};return c(a.resolve(e))}));e.exports.sync=((e,i)=>{s(e);i=Object.assign({},o,i);const t=e=>{try{i.fs.mkdirSync(e,i.mode)}catch(n){if(n.code==="ENOENT"){if(n.message.includes("null bytes")||a.dirname(e)===e){throw n}t(a.dirname(e));return t(e)}try{if(!i.fs.statSync(e).isDirectory()){throw new Error("The path is not a directory")}}catch(e){throw n}}return e};return t(a.resolve(e))})},3:function(e,i,t){var n=t(669);var a=t(45);var r=t(791);var o=t(286);var s=t(441).Writable;var c=t(441).PassThrough;var p=function(){};var u=function(e){e&=511;return e&&512-e};var l=function(e,i){var t=new d(e,i);t.end();return t};var f=function(e,i){if(i.path)e.name=i.path;if(i.linkpath)e.linkname=i.linkpath;if(i.size)e.size=parseInt(i.size,10);e.pax=i;return e};var d=function(e,i){this._parent=e;this.offset=i;c.call(this)};n.inherits(d,c);d.prototype.destroy=function(e){this._parent.destroy(e)};var m=function(e){if(!(this instanceof m))return new m(e);s.call(this,e);e=e||{};this._offset=0;this._buffer=a();this._missing=0;this._partial=false;this._onparse=p;this._header=null;this._stream=null;this._overflow=null;this._cb=null;this._locked=false;this._destroyed=false;this._pax=null;this._paxGlobal=null;this._gnuLongPath=null;this._gnuLongLinkPath=null;var i=this;var t=i._buffer;var n=function(){i._continue()};var c=function(e){i._locked=false;if(e)return i.destroy(e);if(!i._stream)n()};var h=function(){i._stream=null;var e=u(i._header.size);if(e)i._parse(e,x);else i._parse(512,w);if(!i._locked)n()};var x=function(){i._buffer.consume(u(i._header.size));i._parse(512,w);n()};var v=function(){var e=i._header.size;i._paxGlobal=o.decodePax(t.slice(0,e));t.consume(e);h()};var b=function(){var e=i._header.size;i._pax=o.decodePax(t.slice(0,e));if(i._paxGlobal)i._pax=r(i._paxGlobal,i._pax);t.consume(e);h()};var g=function(){var n=i._header.size;this._gnuLongPath=o.decodeLongPath(t.slice(0,n),e.filenameEncoding);t.consume(n);h()};var y=function(){var n=i._header.size;this._gnuLongLinkPath=o.decodeLongPath(t.slice(0,n),e.filenameEncoding);t.consume(n);h()};var w=function(){var a=i._offset;var r;try{r=i._header=o.decode(t.slice(0,512),e.filenameEncoding)}catch(e){i.emit("error",e)}t.consume(512);if(!r){i._parse(512,w);n();return}if(r.type==="gnu-long-path"){i._parse(r.size,g);n();return}if(r.type==="gnu-long-link-path"){i._parse(r.size,y);n();return}if(r.type==="pax-global-header"){i._parse(r.size,v);n();return}if(r.type==="pax-header"){i._parse(r.size,b);n();return}if(i._gnuLongPath){r.name=i._gnuLongPath;i._gnuLongPath=null}if(i._gnuLongLinkPath){r.linkname=i._gnuLongLinkPath;i._gnuLongLinkPath=null}if(i._pax){i._header=r=f(r,i._pax);i._pax=null}i._locked=true;if(!r.size||r.type==="direcLine truncated
|
||||
+8
-5
@@ -3,12 +3,15 @@ import getInputs from './inputs'
|
||||
import setOutputs from './outputs'
|
||||
import install from './install'
|
||||
|
||||
const inputs = getInputs()
|
||||
async function main() {
|
||||
const inputs = await getInputs()
|
||||
await install(inputs).then(() => {
|
||||
console.log('Installation Completed!')
|
||||
setOutputs(inputs)
|
||||
})
|
||||
}
|
||||
|
||||
install(inputs).then(() => {
|
||||
console.log('Installation Completed!')
|
||||
setOutputs(inputs)
|
||||
}).catch(error => {
|
||||
main().catch(error => {
|
||||
console.error(error)
|
||||
setFailed(error)
|
||||
})
|
||||
+17
-4
@@ -1,4 +1,6 @@
|
||||
import { getInput, InputOptions } from '@actions/core'
|
||||
import { inspect } from 'util'
|
||||
import { getInput, error, InputOptions } from '@actions/core'
|
||||
import * as glob from '@actions/glob'
|
||||
|
||||
export interface Inputs {
|
||||
readonly version: string
|
||||
@@ -11,10 +13,21 @@ const options: InputOptions = {
|
||||
required: true,
|
||||
}
|
||||
|
||||
export const getInputs = (): Inputs => ({
|
||||
async function parsePath(pattern: string, inputName: string) {
|
||||
const builder = await glob.create(pattern)
|
||||
const paths = await builder.glob()
|
||||
if (paths.length !== 1) {
|
||||
error(`Input ${inputName} is expected to match 1 path, but it matches ${paths.length}: ${inspect(paths)}`)
|
||||
}
|
||||
return paths[0]
|
||||
}
|
||||
|
||||
const parseInputPath = (name: string) => parsePath(getInput(name, options), name)
|
||||
|
||||
export const getInputs = async (): Promise<Inputs> => ({
|
||||
version: getInput('version', options),
|
||||
dest: getInput('dest', options),
|
||||
binDest: getInput('bin_dest', options),
|
||||
dest: await parseInputPath('dest'),
|
||||
binDest: await parseInputPath('bin_dest'),
|
||||
registry: getInput('registry', options),
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user