@actions/glob
Advanced tools
Comparing version 0.1.0 to 0.1.1
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core = require("@actions/core"); | ||
const core = __importStar(require("@actions/core")); | ||
/** | ||
@@ -5,0 +12,0 @@ * Returns a copy with defaults filled in. |
@@ -8,3 +8,3 @@ import { GlobOptions } from './internal-glob-options'; | ||
/** | ||
* Returns the search path preceeding the first glob segment, from each pattern. | ||
* Returns the search path preceding the first glob segment, from each pattern. | ||
* Duplicates and descendants of other paths are filtered out. | ||
@@ -11,0 +11,0 @@ * |
@@ -30,8 +30,15 @@ "use strict"; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core = require("@actions/core"); | ||
const fs = require("fs"); | ||
const globOptionsHelper = require("./internal-glob-options-helper"); | ||
const path = require("path"); | ||
const patternHelper = require("./internal-pattern-helper"); | ||
const core = __importStar(require("@actions/core")); | ||
const fs = __importStar(require("fs")); | ||
const globOptionsHelper = __importStar(require("./internal-glob-options-helper")); | ||
const path = __importStar(require("path")); | ||
const patternHelper = __importStar(require("./internal-pattern-helper")); | ||
const internal_match_kind_1 = require("./internal-match-kind"); | ||
@@ -38,0 +45,0 @@ const internal_pattern_1 = require("./internal-pattern"); |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const assert = require("assert"); | ||
const path = require("path"); | ||
const path = __importStar(require("path")); | ||
const assert_1 = __importDefault(require("assert")); | ||
const IS_WINDOWS = process.platform === 'win32'; | ||
@@ -44,4 +54,4 @@ /** | ||
function ensureAbsoluteRoot(root, itemPath) { | ||
assert(root, `ensureAbsoluteRoot parameter 'root' must not be empty`); | ||
assert(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`); | ||
assert_1.default(root, `ensureAbsoluteRoot parameter 'root' must not be empty`); | ||
assert_1.default(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`); | ||
// Already rooted | ||
@@ -56,3 +66,3 @@ if (hasAbsoluteRoot(itemPath)) { | ||
let cwd = process.cwd(); | ||
assert(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); | ||
assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); | ||
// Drive letter matches cwd? Expand to cwd | ||
@@ -82,7 +92,7 @@ if (itemPath[0].toUpperCase() === cwd[0].toUpperCase()) { | ||
const cwd = process.cwd(); | ||
assert(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); | ||
assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); | ||
return `${cwd[0]}:\\${itemPath.substr(1)}`; | ||
} | ||
} | ||
assert(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`); | ||
assert_1.default(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`); | ||
// Otherwise ensure root ends with a separator | ||
@@ -104,3 +114,3 @@ if (root.endsWith('/') || (IS_WINDOWS && root.endsWith('\\'))) { | ||
function hasAbsoluteRoot(itemPath) { | ||
assert(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`); | ||
assert_1.default(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`); | ||
// Normalize separators | ||
@@ -122,3 +132,3 @@ itemPath = normalizeSeparators(itemPath); | ||
function hasRoot(itemPath) { | ||
assert(itemPath, `isRooted parameter 'itemPath' must not be empty`); | ||
assert_1.default(itemPath, `isRooted parameter 'itemPath' must not be empty`); | ||
// Normalize separators | ||
@@ -125,0 +135,0 @@ itemPath = normalizeSeparators(itemPath); |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const assert = require("assert"); | ||
const path = require("path"); | ||
const pathHelper = require("./internal-path-helper"); | ||
const path = __importStar(require("path")); | ||
const pathHelper = __importStar(require("./internal-path-helper")); | ||
const assert_1 = __importDefault(require("assert")); | ||
const IS_WINDOWS = process.platform === 'win32'; | ||
@@ -19,3 +29,3 @@ /** | ||
if (typeof itemPath === 'string') { | ||
assert(itemPath, `Parameter 'itemPath' must not be empty`); | ||
assert_1.default(itemPath, `Parameter 'itemPath' must not be empty`); | ||
// Normalize slashes and trim unnecessary trailing slash | ||
@@ -47,3 +57,3 @@ itemPath = pathHelper.safeTrimTrailingSeparator(itemPath); | ||
// Must not be empty | ||
assert(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`); | ||
assert_1.default(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`); | ||
// Each segment | ||
@@ -53,3 +63,3 @@ for (let i = 0; i < itemPath.length; i++) { | ||
// Must not be empty | ||
assert(segment, `Parameter 'itemPath' must not contain any empty segments`); | ||
assert_1.default(segment, `Parameter 'itemPath' must not contain any empty segments`); | ||
// Normalize slashes | ||
@@ -60,3 +70,3 @@ segment = pathHelper.normalizeSeparators(itemPath[i]); | ||
segment = pathHelper.safeTrimTrailingSeparator(segment); | ||
assert(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`); | ||
assert_1.default(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`); | ||
this.segments.push(segment); | ||
@@ -67,3 +77,3 @@ } | ||
// Must not contain slash | ||
assert(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`); | ||
assert_1.default(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`); | ||
this.segments.push(segment); | ||
@@ -70,0 +80,0 @@ } |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const pathHelper = require("./internal-path-helper"); | ||
const pathHelper = __importStar(require("./internal-path-helper")); | ||
const internal_match_kind_1 = require("./internal-match-kind"); | ||
@@ -5,0 +12,0 @@ const IS_WINDOWS = process.platform === 'win32'; |
@@ -13,3 +13,3 @@ import { MatchKind } from './internal-match-kind'; | ||
* The path/pattern segments. Note, only the first segment (the root directory) | ||
* may contain a directory separator charactor. Use the trailingSeparator field | ||
* may contain a directory separator character. Use the trailingSeparator field | ||
* to determine whether the pattern ended with a trailing slash. | ||
@@ -33,2 +33,3 @@ */ | ||
constructor(pattern: string); | ||
constructor(pattern: string, segments: undefined, homedir: string); | ||
constructor(negate: boolean, segments: string[]); | ||
@@ -35,0 +36,0 @@ /** |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const assert = require("assert"); | ||
const os = require("os"); | ||
const path = require("path"); | ||
const pathHelper = require("./internal-path-helper"); | ||
const os = __importStar(require("os")); | ||
const path = __importStar(require("path")); | ||
const pathHelper = __importStar(require("./internal-path-helper")); | ||
const assert_1 = __importDefault(require("assert")); | ||
const minimatch_1 = require("minimatch"); | ||
@@ -12,3 +22,3 @@ const internal_match_kind_1 = require("./internal-match-kind"); | ||
class Pattern { | ||
constructor(patternOrNegate, segments) { | ||
constructor(patternOrNegate, segments, homedir) { | ||
/** | ||
@@ -27,5 +37,5 @@ * Indicates whether matches should be excluded from the result set | ||
segments = segments || []; | ||
assert(segments.length, `Parameter 'segments' must not empty`); | ||
assert_1.default(segments.length, `Parameter 'segments' must not empty`); | ||
const root = Pattern.getLiteral(segments[0]); | ||
assert(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`); | ||
assert_1.default(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`); | ||
pattern = new internal_path_1.Path(segments).toString().trim(); | ||
@@ -42,3 +52,3 @@ if (patternOrNegate) { | ||
// Normalize slashes and ensures absolute root | ||
pattern = Pattern.fixupPattern(pattern); | ||
pattern = Pattern.fixupPattern(pattern, homedir); | ||
// Segments | ||
@@ -80,7 +90,7 @@ this.segments = new internal_path_1.Path(pattern).segments; | ||
// Append a trailing slash. Otherwise Minimatch will not match the directory immediately | ||
// preceeding the globstar. For example, given the pattern `/foo/**`, Minimatch returns | ||
// preceding the globstar. For example, given the pattern `/foo/**`, Minimatch returns | ||
// false for `/foo` but returns true for `/foo/`. Append a trailing slash to handle that quirk. | ||
if (!itemPath.endsWith(path.sep)) { | ||
// Note, this is safe because the constructor ensures the pattern has an absolute root. | ||
// For example, formats like C: and C:foo on Windows are resolved to an aboslute root. | ||
// For example, formats like C: and C:foo on Windows are resolved to an absolute root. | ||
itemPath = `${itemPath}${path.sep}`; | ||
@@ -123,11 +133,11 @@ } | ||
*/ | ||
static fixupPattern(pattern) { | ||
static fixupPattern(pattern, homedir) { | ||
// Empty | ||
assert(pattern, 'pattern cannot be empty'); | ||
assert_1.default(pattern, 'pattern cannot be empty'); | ||
// Must not contain `.` segment, unless first segment | ||
// Must not contain `..` segment | ||
const literalSegments = new internal_path_1.Path(pattern).segments.map(x => Pattern.getLiteral(x)); | ||
assert(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`); | ||
assert_1.default(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`); | ||
// Must not contain globs in root, e.g. Windows UNC path \\foo\b*r | ||
assert(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`); | ||
assert_1.default(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`); | ||
// Normalize slashes | ||
@@ -141,5 +151,5 @@ pattern = pathHelper.normalizeSeparators(pattern); | ||
else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) { | ||
const homedir = os.homedir(); | ||
assert(homedir, 'Unable to determine HOME directory'); | ||
assert(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`); | ||
homedir = homedir || os.homedir(); | ||
assert_1.default(homedir, 'Unable to determine HOME directory'); | ||
assert_1.default(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`); | ||
pattern = Pattern.globEscape(homedir) + pattern.substr(1); | ||
@@ -146,0 +156,0 @@ } |
{ | ||
"name": "@actions/glob", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"preview": true, | ||
@@ -11,3 +11,3 @@ "description": "Actions glob lib", | ||
], | ||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/glob", | ||
"homepage": "https://github.com/actions/toolkit/tree/main/packages/glob", | ||
"license": "MIT", | ||
@@ -21,3 +21,4 @@ "main": "lib/glob.js", | ||
"files": [ | ||
"lib" | ||
"lib", | ||
"!.DS_Store" | ||
], | ||
@@ -33,3 +34,3 @@ "publishConfig": { | ||
"scripts": { | ||
"audit-moderate": "npm install && npm audit --audit-level=moderate", | ||
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json", | ||
"test": "echo \"Error: run tests from root\" && exit 1", | ||
@@ -42,5 +43,5 @@ "tsc": "tsc" | ||
"dependencies": { | ||
"@actions/core": "^1.2.0", | ||
"@actions/core": "^1.2.6", | ||
"minimatch": "^3.0.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
72919
33
1147
0
114
1
Updated@actions/core@^1.2.6