Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion example-project/src-client/auth/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {

function authenticate(provider) {
return dispatch => {
//cc:signin#1;firebase sign in;+1;call to firebase with auth provider, proceed if success response
/*
* cc:signin#1;firebase sign in;+1;call to firebase with auth provider, proceed if success response
*/
firebaseAuth.signInWithPopup(provider)
.then(result => dispatch(signInSuccess(result)))
.catch(error => dispatch(signInError(error)));
Expand Down
42 changes: 18 additions & 24 deletions src/server/code-parse/language/default/codecrumbs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const compact = require('lodash/compact');
const { CC_NODE_TYPE, NO_TRAIL_FLOW } = require('../../../shared-constants');

const CRUMB = 'codecrumb',
CRUMB_SHORT_HANDLER = 'cc';
const CRUMB_REGEX = /cc|codecrumb/;
const DEFAULT_COMMENT_REGEX = /\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm;

const getCommentNodeValue = node => (node.value || '').trim();

Expand Down Expand Up @@ -38,12 +39,7 @@ const parseCodecrumbComment = (node = {}) => {
return cc;
};

const isCodecrumb = node => {
if (!node) return false;

const comment = getCommentNodeValue(node);
return comment.startsWith(CRUMB) || comment.startsWith(CRUMB_SHORT_HANDLER);
};
const isCodecrumb = node => CRUMB_REGEX.test(getCommentNodeValue(node));

const buildCrumb = (params, crumbNodeLines, path) => ({
type: CC_NODE_TYPE,
Expand All @@ -57,22 +53,21 @@ const buildCrumb = (params, crumbNodeLines, path) => ({
});

const setupGetCommentsFromCode = regex => fileCode => {
if (!fileCode) return [];

return fileCode.split('\n').reduce((comments, item, i) => {
const codeLine = item.trim();
if (!codeLine) return comments;

const matches = regex.exec(codeLine);
if (matches) {
const lineNumber = i + 1;
return [
...comments,
{ value: matches[matches.length - 1], nodeLines: [lineNumber, lineNumber] }
];
}
if (!fileCode) {
return [];
}

const result = compact(regex.exec(fileCode)) || [];

return result.reduce((comments, value) => {
value = value.trim()
const index = fileCode.indexOf(value);
const tempString = fileCode.substring(0, index);
const matchLineNumber = tempString.split('\n').length;

return comments;
const commentStringCount = value.split('\n').length
const nodeLines = [matchLineNumber, matchLineNumber + commentStringCount - 1];
return [...comments, { value, nodeLines }]
}, []);
};

Expand All @@ -99,7 +94,6 @@ const setupGetCrumbs = getCommentsFromCode => (fileCode, path) => {
}
};

const DEFAULT_COMMENT_REGEX = /^([^\/\/]*)\/\/(.*)$/;
const getCrumbs = setupGetCrumbs(setupGetCommentsFromCode(DEFAULT_COMMENT_REGEX));

module.exports = {
Expand Down
7 changes: 6 additions & 1 deletion src/server/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ const logAdapter = msg => console.log(msg);
module.exports = {
getText: e => {
try {
return typeof e === 'object' ? JSON.stringify(e) : e;
if (typeof e === 'object') {
const stringifiedError = JSON.stringify(e);
return stringifiedError === '{}' ? e : stringifiedError;
} else {
return e;
}
} catch (e) {
return `COULD NOT PARSE ERROR ${e}`;
}
Expand Down