-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds the ability to pass in a publish file location #20
Open
designfrontier
wants to merge
3
commits into
master
Choose a base branch
from
feature/add-passed-in-publish-script-location
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Adds the ability to pass in a publish file location #20
designfrontier
wants to merge
3
commits into
master
from
feature/add-passed-in-publish-script-location
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This lets you pass in the publish script's location as a command line argument.
@rwstauner @phallstrom If you guys want to put this through its paces... |
The test are breaking for other reasons... that are unrelated |
it needs at least: diff --git a/modules/check-ownership.js b/modules/check-ownership.js
index 1196f41..7eca67f 100644
--- a/modules/check-ownership.js
+++ b/modules/check-ownership.js
@@ -1,4 +1,5 @@
const cp = require('child_process')
+ fs = require('fs')
path = require('path');
module.exports = (details, publish) => {
@@ -6,12 +7,12 @@ module.exports = (details, publish) => {
const ownership = (ownedLines / size) * 100;
const publishFile = path.join(process.cwd(), config.publish);
- if (ownership >= config.threshold /*&& author !== currentAuthor*/) {
+ if (ownership >= config.threshold && author !== currentAuthor) {
if (publish) {
try {
fs.statSync(publishFile).isFile();
} catch (e) {
- console.log('Your publish script does not seem to exist?');
+ console.log(`Your publish script (${publishFile}) does not seem to exist: ${e}`);
process.exit(1);
} |
possibly diff --git a/modules/check-ownership.js b/modules/check-ownership.js
index 1196f41..7a017c3 100644
--- a/modules/check-ownership.js
+++ b/modules/check-ownership.js
@@ -1,17 +1,18 @@
const cp = require('child_process')
+ fs = require('fs')
path = require('path');
module.exports = (details, publish) => {
const { size, ownedLines, author, filePath, currentAuthor, config } = details;
const ownership = (ownedLines / size) * 100;
- const publishFile = path.join(process.cwd(), config.publish);
+ const publishFile = config.publish;
- if (ownership >= config.threshold /*&& author !== currentAuthor*/) {
+ if (ownership >= config.threshold && author !== currentAuthor) {
if (publish) {
try {
fs.statSync(publishFile).isFile();
} catch (e) {
- console.log('Your publish script does not seem to exist?');
+ console.log(`Your publish script (${publishFile}) does not seem to exist: ${e}`);
process.exit(1);
}
diff --git a/modules/read-config.js b/modules/read-config.js
index 5a270c9..47813fe 100644
--- a/modules/read-config.js
+++ b/modules/read-config.js
@@ -7,7 +7,8 @@ module.exports = ({ location = '.pythia-config', publish}) => {
const configFile = fs.existsSync(filePath) ? readFile(filePath) : {};
const exclude = configFile.exclude ? readFile(filePath).exclude : {};
const threshold = configFile.threshold || 20;
- const publishFinal = publish || configFile.publish || '.pythia-publish';
+ const publishBase = publish || configFile.publish || '.pythia-publish';
+ const publishPath = path.isAbsolute(publishBase) ? publishBase : path.join(process.cwd(), publishBase);
['users', 'directories', 'files'].forEach((item) => {
if (typeof exclude[item] === 'undefined') {
@@ -15,11 +16,11 @@ module.exports = ({ location = '.pythia-config', publish}) => {
}
});
- if (publish) {
+ if (publishPath) {
try {
- fs.statSync(path.join(process.cwd(), publish)).isFile();
+ fs.statSync(publishPath).isFile();
} catch (e) {
- console.log('Please provide a file with your --publish or -p flag');
+ console.log(`Please provide a file with your --publish or -p flag (${publishPath} does not exist)`);
process.exit(1);
}
}
@@ -27,6 +28,6 @@ module.exports = ({ location = '.pythia-config', publish}) => {
return {
exclude,
threshold,
- publish: publishFinal
+ publish: publishPath
};
}; |
…lish script, and makes things bettah'
Can't believe I left that author line commented out. Added your suggestions and centralized handling of the publish file existence to a single location. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This lets you pass in the publish script's location as
a command line argument. Also fixes some bugs that were found in doing that work.
closes #15