Skip to content

Commit

Permalink
fix: path was sometimes empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Aug 2, 2020
1 parent 9f0933c commit 37d7741
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 84 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Automate releases with Conventional Commit Messages.
release-please:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v1.6.2
- uses: GoogleCloudPlatform/release-please-action@v1.6.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v1.6.2
- uses: GoogleCloudPlatform/release-please-action@v1.6.3
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
192 changes: 112 additions & 80 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ async function main () {
const bumpMinorPreMajor = Boolean(core.getInput('bump-minor-pre-major'))
const monorepoTags = Boolean(core.getInput('monorepo-tags'))
const packageName = core.getInput('package-name')
const path = core.getInput('path')
const path = core.getInput('path') ? core.getInput('path') : undefined
const releaseType = core.getInput('release-type')
const token = core.getInput('token')

Expand All @@ -1742,7 +1742,7 @@ async function main () {
label: RELEASE_LABEL,
repoUrl: process.env.GITHUB_REPOSITORY,
packageName,
path: path ? path : undefined,
path,
token
})
const releaseCreated = await gr.createRelease()
Expand Down Expand Up @@ -3138,116 +3138,147 @@ SafeBuffer.allocUnsafeSlow = function (size) {

"use strict";

var isObj = __webpack_require__(804);
const isObj = __webpack_require__(804);

module.exports.get = function (obj, path) {
if (!isObj(obj) || typeof path !== 'string') {
return obj;
}
const disallowedKeys = [
'__proto__',
'prototype',
'constructor'
];

var pathArr = getPathSegments(path);
const isValidPath = pathSegments => !pathSegments.some(segment => disallowedKeys.includes(segment));

for (var i = 0; i < pathArr.length; i++) {
var descriptor = Object.getOwnPropertyDescriptor(obj, pathArr[i]) || Object.getOwnPropertyDescriptor(Object.prototype, pathArr[i]);
if (descriptor && !descriptor.enumerable) {
return;
function getPathSegments(path) {
const pathArray = path.split('.');
const parts = [];

for (let i = 0; i < pathArray.length; i++) {
let p = pathArray[i];

while (p[p.length - 1] === '\\' && pathArray[i + 1] !== undefined) {
p = p.slice(0, -1) + '.';
p += pathArray[++i];
}

obj = obj[pathArr[i]];
parts.push(p);
}

if (obj === undefined || obj === null) {
// `obj` is either `undefined` or `null` so we want to stop the loop, and
// if this is not the last bit of the path, and
// if it did't return `undefined`
// it would return `null` if `obj` is `null`
// but we want `get({foo: null}, 'foo.bar')` to equal `undefined` not `null`
if (i !== pathArr.length - 1) {
return undefined;
}
if (!isValidPath(parts)) {
return [];
}

break;
return parts;
}

module.exports = {
get(object, path, value) {
if (!isObj(object) || typeof path !== 'string') {
return value === undefined ? object : value;
}
}

return obj;
};
const pathArray = getPathSegments(path);
if (pathArray.length === 0) {
return;
}

module.exports.set = function (obj, path, value) {
if (!isObj(obj) || typeof path !== 'string') {
return;
}
for (let i = 0; i < pathArray.length; i++) {
if (!Object.prototype.propertyIsEnumerable.call(object, pathArray[i])) {
return value;
}

var pathArr = getPathSegments(path);
object = object[pathArray[i]];

for (var i = 0; i < pathArr.length; i++) {
var p = pathArr[i];
if (object === undefined || object === null) {
// `object` is either `undefined` or `null` so we want to stop the loop, and
// if this is not the last bit of the path, and
// if it did't return `undefined`
// it would return `null` if `object` is `null`
// but we want `get({foo: null}, 'foo.bar')` to equal `undefined`, or the supplied value, not `null`
if (i !== pathArray.length - 1) {
return value;
}

if (!isObj(obj[p])) {
obj[p] = {};
break;
}
}

if (i === pathArr.length - 1) {
obj[p] = value;
return object;
},

set(object, path, value) {
if (!isObj(object) || typeof path !== 'string') {
return object;
}

obj = obj[p];
}
};
const root = object;
const pathArray = getPathSegments(path);

module.exports.delete = function (obj, path) {
if (!isObj(obj) || typeof path !== 'string') {
return;
}
for (let i = 0; i < pathArray.length; i++) {
const p = pathArray[i];

var pathArr = getPathSegments(path);
if (!isObj(object[p])) {
object[p] = {};
}

for (var i = 0; i < pathArr.length; i++) {
var p = pathArr[i];
if (i === pathArray.length - 1) {
object[p] = value;
}

if (i === pathArr.length - 1) {
delete obj[p];
object = object[p];
}

return root;
},

delete(object, path) {
if (!isObj(object) || typeof path !== 'string') {
return;
}

obj = obj[p];
}
};
const pathArray = getPathSegments(path);

module.exports.has = function (obj, path) {
if (!isObj(obj) || typeof path !== 'string') {
return false;
}
for (let i = 0; i < pathArray.length; i++) {
const p = pathArray[i];

var pathArr = getPathSegments(path);
if (i === pathArray.length - 1) {
delete object[p];
return;
}

for (var i = 0; i < pathArr.length; i++) {
obj = obj[pathArr[i]];
object = object[p];

if (obj === undefined) {
return false;
if (!isObj(object)) {
return;
}
}
}
},

return true;
};
has(object, path) {
if (!isObj(object) || typeof path !== 'string') {
return false;
}

function getPathSegments(path) {
var pathArr = path.split('.');
var parts = [];
const pathArray = getPathSegments(path);
if (pathArray.length === 0) {
return false;
}

for (var i = 0; i < pathArr.length; i++) {
var p = pathArr[i];
// eslint-disable-next-line unicorn/no-for-loop
for (let i = 0; i < pathArray.length; i++) {
if (isObj(object)) {
if (!(pathArray[i] in object)) {
return false;
}

while (p[p.length - 1] === '\\' && pathArr[i + 1] !== undefined) {
p = p.slice(0, -1) + '.';
p += pathArr[++i];
object = object[pathArray[i]];
} else {
return false;
}
}

parts.push(p);
return true;
}

return parts;
}
};


/***/ }),
Expand Down Expand Up @@ -3644,7 +3675,7 @@ const parserOpts = __webpack_require__(239)
const writerOpts = __webpack_require__(579)

module.exports = function (config) {
return Q.all([parserOpts, writerOpts])
return Q.all([parserOpts(config), writerOpts(config)])
.spread((parserOpts, writerOpts) => {
return { parserOpts, writerOpts }
})
Expand Down Expand Up @@ -42998,9 +43029,10 @@ module.exports = minor

"use strict";

module.exports = function (x) {
var type = typeof x;
return x !== null && (type === 'object' || type === 'function');

module.exports = value => {
const type = typeof value;
return value !== null && (type === 'object' || type === 'function');
};


Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async function main () {
const bumpMinorPreMajor = Boolean(core.getInput('bump-minor-pre-major'))
const monorepoTags = Boolean(core.getInput('monorepo-tags'))
const packageName = core.getInput('package-name')
const path = core.getInput('path')
const path = core.getInput('path') ? core.getInput('path') : undefined
const releaseType = core.getInput('release-type')
const token = core.getInput('token')

Expand All @@ -18,7 +18,7 @@ async function main () {
label: RELEASE_LABEL,
repoUrl: process.env.GITHUB_REPOSITORY,
packageName,
path: path ? path : undefined,
path,
token
})
const releaseCreated = await gr.createRelease()
Expand Down

0 comments on commit 37d7741

Please sign in to comment.