update eslint and fix linting errors

This commit is contained in:
Cassie Tarakajian 2018-05-04 17:22:39 -07:00
parent 254bbacba2
commit c90dac55b7
35 changed files with 1230 additions and 1512 deletions

View file

@ -404,7 +404,8 @@ class Nav extends React.PureComponent {
onFocus={this.handleFocus.bind(this, 'help')} onFocus={this.handleFocus.bind(this, 'help')}
onBlur={this.handleBlur} onBlur={this.handleBlur}
onClick={this.setDropdown.bind(this, 'none')} onClick={this.setDropdown.bind(this, 'none')}
>Reference</a> >Reference
</a>
</li> </li>
<li className="nav__dropdown-item"> <li className="nav__dropdown-item">
<Link <Link

View file

@ -3,11 +3,9 @@ import { createDevTools } from 'redux-devtools';
import LogMonitor from 'redux-devtools-log-monitor'; import LogMonitor from 'redux-devtools-log-monitor';
import DockMonitor from 'redux-devtools-dock-monitor'; import DockMonitor from 'redux-devtools-dock-monitor';
export default createDevTools( export default createDevTools(<DockMonitor
<DockMonitor
toggleVisibilityKey="ctrl-h" toggleVisibilityKey="ctrl-h"
changePositionKey="ctrl-w" changePositionKey="ctrl-w"
> >
<LogMonitor /> <LogMonitor />
</DockMonitor> </DockMonitor>);
);

View file

@ -273,9 +273,7 @@ export function setServeSecure(serveSecure, { redirect = true } = {}) {
if (redirect === true) { if (redirect === true) {
dispatch(saveProject(false /* autosave */)) dispatch(saveProject(false /* autosave */))
.then( .then(() => redirectToProtocol(serveSecure === true ? protocols.https : protocols.http));
() => redirectToProtocol(serveSecure === true ? protocols.https : protocols.http)
);
} }
return null; return null;

View file

@ -47,7 +47,8 @@ export function dropzoneAcceptCallback(userId, file, done) {
}); });
} else { } else {
file.postData = []; // eslint-disable-line file.postData = []; // eslint-disable-line
axios.post(`${ROOT_URL}/S3/sign`, { axios.post(
`${ROOT_URL}/S3/sign`, {
name: file.name, name: file.name,
type: file.type, type: file.type,
size: file.size, size: file.size,
@ -56,7 +57,8 @@ export function dropzoneAcceptCallback(userId, file, done) {
}, },
{ {
withCredentials: true withCredentials: true
}) }
)
.then((response) => { .then((response) => {
file.custom_status = 'ready'; // eslint-disable-line file.custom_status = 'ready'; // eslint-disable-line
file.postData = response.data; // eslint-disable-line file.postData = response.data; // eslint-disable-line

View file

@ -34,7 +34,8 @@ function About(props) {
rel="noopener noreferrer" rel="noopener noreferrer"
> >
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> <InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Examples</a> Examples
</a>
</p> </p>
<p className="about__content-column-list"> <p className="about__content-column-list">
<a <a
@ -43,7 +44,8 @@ function About(props) {
rel="noopener noreferrer" rel="noopener noreferrer"
> >
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> <InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Learn</a> Learn
</a>
</p> </p>
</div> </div>
<div className="about__content-column"> <div className="about__content-column">
@ -55,7 +57,8 @@ function About(props) {
rel="noopener noreferrer" rel="noopener noreferrer"
> >
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> <InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Libraries</a> Libraries
</a>
</p> </p>
<p className="about__content-column-list"> <p className="about__content-column-list">
<a <a
@ -64,7 +67,8 @@ function About(props) {
rel="noopener noreferrer" rel="noopener noreferrer"
> >
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> <InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Reference</a> Reference
</a>
</p> </p>
<p className="about__content-column-list"> <p className="about__content-column-list">
<a <a
@ -73,7 +77,8 @@ function About(props) {
rel="noopener noreferrer" rel="noopener noreferrer"
> >
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> <InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Forum</a> Forum
</a>
</p> </p>
</div> </div>
<div className="about__footer"> <div className="about__footer">
@ -82,21 +87,24 @@ function About(props) {
href="https://github.com/processing/p5.js-web-editor" href="https://github.com/processing/p5.js-web-editor"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
>Contribute</a> >Contribute
</a>
</p> </p>
<p className="about__footer-list"> <p className="about__footer-list">
<a <a
href="https://github.com/processing/p5.js-web-editor/issues/new" href="https://github.com/processing/p5.js-web-editor/issues/new"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
>Report a bug</a> >Report a bug
</a>
</p> </p>
<p className="about__footer-list"> <p className="about__footer-list">
<a <a
href="https://twitter.com/p5xjs?lang=en" href="https://twitter.com/p5xjs?lang=en"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
>Twitter</a> >Twitter
</a>
</p> </p>
</div> </div>
</div> </div>

View file

@ -44,13 +44,12 @@ class AssetList extends React.Component {
</thead> </thead>
<tbody> <tbody>
{this.props.assets.map(asset => {this.props.assets.map(asset =>
<tr className="asset-table__row" key={asset.key}> (<tr className="asset-table__row" key={asset.key}>
<td>{asset.name}</td> <td>{asset.name}</td>
<td>{prettyBytes(asset.size)}</td> <td>{prettyBytes(asset.size)}</td>
<td><Link to={asset.url} target="_blank">View</Link></td> <td><Link to={asset.url} target="_blank">View</Link></td>
<td><Link to={`/${this.props.username}/sketches/${asset.sketchId}`}>{asset.sketchName}</Link></td> <td><Link to={`/${this.props.username}/sketches/${asset.sketchId}`}>{asset.sketchName}</Link></td>
</tr> </tr>))}
)}
</tbody> </tbody>
</table>} </table>}
</div> </div>

View file

@ -44,7 +44,7 @@ class Console extends React.Component {
if (Object.keys(args).length === 0) { if (Object.keys(args).length === 0) {
return ( return (
<div key={consoleEvent.id} className="preview-console__undefined"> <div key={consoleEvent.id} className="preview-console__undefined">
<span key={`${consoleEvent.id}-0`}>{'undefined'}</span> <span key={`${consoleEvent.id}-0`}>undefined</span>
</div> </div>
); );
} }
@ -58,7 +58,6 @@ class Console extends React.Component {
</div> </div>
); );
} }
} }
Console.propTypes = { Console.propTypes = {

View file

@ -9,18 +9,14 @@ class EditorAccessibility extends React.Component {
const messages = []; const messages = [];
if (this.props.lintMessages.length > 0) { if (this.props.lintMessages.length > 0) {
this.props.lintMessages.forEach((lintMessage, i) => { this.props.lintMessages.forEach((lintMessage, i) => {
messages.push( messages.push(<li key={lintMessage.id}>
<li key={lintMessage.id}>
{lintMessage.severity} in line {lintMessage.severity} in line
{lintMessage.line} : {lintMessage.line} :
{lintMessage.message} {lintMessage.message}
</li> </li>);
);
}); });
} else { } else {
messages.push( messages.push(<li tabIndex="0" key={0}> There are no lint messages </li>);
<li tabIndex="0" key={0}> There are no lint messages </li>
);
} }
return ( return (
<div className="editor-accessibility"> <div className="editor-accessibility">

View file

@ -40,7 +40,8 @@ function Feedback(props) {
href="https://docs.google.com/forms/d/e/1FAIpQLSexU8W2EIhXjktl-_XzwjH6vgnelHirH4Yn4liN5BXltPWqBg/viewform" href="https://docs.google.com/forms/d/e/1FAIpQLSexU8W2EIhXjktl-_XzwjH6vgnelHirH4Yn4liN5BXltPWqBg/viewform"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
>Go to Form</a> >Go to Form
</a>
</p> </p>
</div> </div>
</div> </div>

View file

@ -23,7 +23,6 @@ import { hijackConsole, hijackConsoleErrorsScript, startTag, getAllScriptOffsets
class PreviewFrame extends React.Component { class PreviewFrame extends React.Component {
componentDidMount() { componentDidMount() {
if (this.props.isPlaying) { if (this.props.isPlaying) {
this.renderFrameContents(); this.renderFrameContents();
@ -144,9 +143,7 @@ class PreviewFrame extends React.Component {
hijackConsole hijackConsole
]; ];
const accessiblelib = sketchDoc.createElement('script'); const accessiblelib = sketchDoc.createElement('script');
accessiblelib.setAttribute( accessiblelib.setAttribute('src', 'https://cdn.rawgit.com/processing/p5.accessibility/v0.1.1/dist/p5-accessibility.js');
'src', 'https://cdn.rawgit.com/processing/p5.accessibility/v0.1.1/dist/p5-accessibility.js'
);
const accessibleOutputs = sketchDoc.createElement('section'); const accessibleOutputs = sketchDoc.createElement('section');
accessibleOutputs.setAttribute('id', 'accessible-outputs'); accessibleOutputs.setAttribute('id', 'accessible-outputs');
accessibleOutputs.setAttribute('aria-label', 'accessible-output'); accessibleOutputs.setAttribute('aria-label', 'accessible-output');

View file

@ -75,8 +75,7 @@ class SketchList extends React.Component {
<th scope="row"><Link to={`/${username}/sketches/${sketch.id}`}>{sketch.name}</Link></th> <th scope="row"><Link to={`/${username}/sketches/${sketch.id}`}>{sketch.name}</Link></th>
<td>{moment(sketch.createdAt).format('MMM D, YYYY h:mm A')}</td> <td>{moment(sketch.createdAt).format('MMM D, YYYY h:mm A')}</td>
<td>{moment(sketch.updatedAt).format('MMM D, YYYY h:mm A')}</td> <td>{moment(sketch.updatedAt).format('MMM D, YYYY h:mm A')}</td>
</tr> </tr>)}
)}
</tbody> </tbody>
</table>} </table>}
</div> </div>

View file

@ -311,7 +311,7 @@ class IDEView extends React.Component {
/> />
<SplitPane <SplitPane
split="vertical" split="vertical"
defaultSize={'50%'} defaultSize="50%"
onChange={() => { this.overlay.style.display = 'block'; }} onChange={() => { this.overlay.style.display = 'block'; }}
onDragFinished={() => { this.overlay.style.display = 'none'; }} onDragFinished={() => { this.overlay.style.display = 'none'; }}
resizerStyle={{ marginRight: '5px' }} resizerStyle={{ marginRight: '5px' }}
@ -691,7 +691,9 @@ function mapStateToProps(state) {
} }
function mapDispatchToProps(dispatch) { function mapDispatchToProps(dispatch) {
return bindActionCreators(Object.assign({}, return bindActionCreators(
Object.assign(
{},
EditorAccessibilityActions, EditorAccessibilityActions,
FileActions, FileActions,
ProjectActions, ProjectActions,
@ -699,8 +701,10 @@ function mapDispatchToProps(dispatch) {
PreferencesActions, PreferencesActions,
UserActions, UserActions,
ToastActions, ToastActions,
ConsoleActions), ConsoleActions
dispatch); ),
dispatch
);
} }
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(IDEView)); export default withRouter(connect(mapStateToProps, mapDispatchToProps)(IDEView));

View file

@ -10,8 +10,9 @@ const editorAccessibility = (state = initialState, action) => {
case ActionTypes.UPDATE_LINT_MESSAGE: case ActionTypes.UPDATE_LINT_MESSAGE:
messageId += 1; messageId += 1;
return Object.assign({}, state, { return Object.assign({}, state, {
lintMessages: state.lintMessages.concat( lintMessages: state.lintMessages.concat({
{ severity: action.severity, line: action.line, message: action.message, id: messageId }) severity: action.severity, line: action.line, message: action.message, id: messageId
})
}); });
case ActionTypes.CLEAR_LINT_MESSAGE: case ActionTypes.CLEAR_LINT_MESSAGE:
return Object.assign({}, state, { lintMessages: [] }); return Object.assign({}, state, { lintMessages: [] });

View file

@ -145,13 +145,15 @@ const files = (state, action) => {
return file; return file;
}); });
return [...newState, return [...newState,
{ name: action.name, {
name: action.name,
id: action.id, id: action.id,
_id: action._id, _id: action._id,
content: action.content, content: action.content,
url: action.url, url: action.url,
children: action.children, children: action.children,
fileType: action.fileType || 'file' }]; fileType: action.fileType || 'file'
}];
} }
case ActionTypes.SHOW_FILE_OPTIONS: case ActionTypes.SHOW_FILE_OPTIONS:
return state.map((file) => { return state.map((file) => {

View file

@ -6,8 +6,7 @@ const sketches = (state = [], action) => {
return action.projects; return action.projects;
case ActionTypes.DELETE_PROJECT: case ActionTypes.DELETE_PROJECT:
return state.filter(sketch => return state.filter(sketch =>
sketch.id !== action.id sketch.id !== action.id);
);
default: default:
return state; return state;
} }

View file

@ -17,7 +17,8 @@ export function signUpUser(previousPath, formValues) {
return (dispatch) => { return (dispatch) => {
axios.post(`${ROOT_URL}/signup`, formValues, { withCredentials: true }) axios.post(`${ROOT_URL}/signup`, formValues, { withCredentials: true })
.then((response) => { .then((response) => {
dispatch({ type: ActionTypes.AUTH_USER, dispatch({
type: ActionTypes.AUTH_USER,
user: response.data user: response.data
}); });
dispatch(justOpenedProject()); dispatch(justOpenedProject());
@ -49,7 +50,8 @@ export function validateAndLoginUser(previousPath, formProps, dispatch) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
loginUser(formProps) loginUser(formProps)
.then((response) => { .then((response) => {
dispatch({ type: ActionTypes.AUTH_USER, dispatch({
type: ActionTypes.AUTH_USER,
user: response.data user: response.data
}); });
dispatch({ dispatch({

View file

@ -4,7 +4,9 @@ import { domOnlyProps } from '../../../utils/reduxFormUtils';
function AccountForm(props) { function AccountForm(props) {
const { const {
fields: { username, email, currentPassword, newPassword }, fields: {
username, email, currentPassword, newPassword
},
user, user,
handleSubmit, handleSubmit,
initiateVerification, initiateVerification,
@ -45,7 +47,8 @@ function AccountForm(props) {
<button <button
className="form__action" className="form__action"
onClick={handleInitiateVerification} onClick={handleInitiateVerification}
>Resend confirmation email</button> >Resend confirmation email
</button>
) )
} }
</p> </p>

View file

@ -3,7 +3,9 @@ import React from 'react';
import { domOnlyProps } from '../../../utils/reduxFormUtils'; import { domOnlyProps } from '../../../utils/reduxFormUtils';
function LoginForm(props) { function LoginForm(props) {
const { fields: { email, password }, handleSubmit, submitting, pristine } = props; const {
fields: { email, password }, handleSubmit, submitting, pristine
} = props;
return ( return (
<form className="form" onSubmit={handleSubmit(props.validateAndLoginUser.bind(this, props.previousPath))}> <form className="form" onSubmit={handleSubmit(props.validateAndLoginUser.bind(this, props.previousPath))}>
<p className="form__field"> <p className="form__field">

View file

@ -3,7 +3,9 @@ import React from 'react';
import { domOnlyProps } from '../../../utils/reduxFormUtils'; import { domOnlyProps } from '../../../utils/reduxFormUtils';
function NewPasswordForm(props) { function NewPasswordForm(props) {
const { fields: { password, confirmPassword }, handleSubmit, submitting, invalid, pristine } = props; const {
fields: { password, confirmPassword }, handleSubmit, submitting, invalid, pristine
} = props;
return ( return (
<form className="form" onSubmit={handleSubmit(props.updatePassword.bind(this, props.params.reset_password_token))}> <form className="form" onSubmit={handleSubmit(props.updatePassword.bind(this, props.params.reset_password_token))}>
<p className="form__field"> <p className="form__field">

View file

@ -3,7 +3,9 @@ import React from 'react';
import { domOnlyProps } from '../../../utils/reduxFormUtils'; import { domOnlyProps } from '../../../utils/reduxFormUtils';
function ResetPasswordForm(props) { function ResetPasswordForm(props) {
const { fields: { email }, handleSubmit, submitting, invalid, pristine } = props; const {
fields: { email }, handleSubmit, submitting, invalid, pristine
} = props;
return ( return (
<form className="form" onSubmit={handleSubmit(props.initiateResetPassword.bind(this))}> <form className="form" onSubmit={handleSubmit(props.initiateResetPassword.bind(this))}>
<p className="form__field"> <p className="form__field">

View file

@ -3,7 +3,11 @@ import React from 'react';
import { domOnlyProps } from '../../../utils/reduxFormUtils'; import { domOnlyProps } from '../../../utils/reduxFormUtils';
function SignupForm(props) { function SignupForm(props) {
const { fields: { username, email, password, confirmPassword }, handleSubmit, submitting, invalid, pristine } = props; const {
fields: {
username, email, password, confirmPassword
}, handleSubmit, submitting, invalid, pristine
} = props;
return ( return (
<form className="form" onSubmit={handleSubmit(props.signUpUser.bind(this, props.previousPath))}> <form className="form" onSubmit={handleSubmit(props.signUpUser.bind(this, props.previousPath))}>
<p className="form__field"> <p className="form__field">

View file

@ -3,8 +3,10 @@ import * as ActionTypes from '../../constants';
const user = (state = { authenticated: false }, action) => { const user = (state = { authenticated: false }, action) => {
switch (action.type) { switch (action.type) {
case ActionTypes.AUTH_USER: case ActionTypes.AUTH_USER:
return { ...action.user, return {
authenticated: true }; ...action.user,
authenticated: true
};
case ActionTypes.UNAUTH_USER: case ActionTypes.UNAUTH_USER:
return { return {
authenticated: false authenticated: false

2244
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -36,11 +36,11 @@
"chunk-manifest-webpack-plugin": "^1.1.2", "chunk-manifest-webpack-plugin": "^1.1.2",
"css-loader": "^0.23.1", "css-loader": "^0.23.1",
"cssnano": "^3.7.1", "cssnano": "^3.7.1",
"eslint": "^3.14.0", "eslint": "^4.9.0",
"eslint-config-airbnb": "^14.0.0", "eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.2.0", "eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2", "eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^6.9.0", "eslint-plugin-react": "^7.7.0",
"extract-text-webpack-plugin": "^3.0.2", "extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^0.8.5", "file-loader": "^0.8.5",
"node-sass": "^4.5.3", "node-sass": "^4.5.3",

View file

@ -9,7 +9,8 @@ import { deleteObjectsFromS3, getObjectKey } from './aws.controller';
// be fixed in mongoose soon // be fixed in mongoose soon
// https://github.com/Automattic/mongoose/issues/4049 // https://github.com/Automattic/mongoose/issues/4049
export function createFile(req, res) { export function createFile(req, res) {
Project.findByIdAndUpdate(req.params.project_id, Project.findByIdAndUpdate(
req.params.project_id,
{ {
$push: { $push: {
files: req.body files: req.body
@ -33,7 +34,8 @@ export function createFile(req, res) {
} }
res.json(updatedProject.files[updatedProject.files.length - 1]); res.json(updatedProject.files[updatedProject.files.length - 1]);
}); });
}); }
);
} }
function getAllDescendantIds(files, nodeId) { function getAllDescendantIds(files, nodeId) {

View file

@ -20,7 +20,8 @@ export function createProject(req, res) {
res.json({ success: false }); res.json({ success: false });
return; return;
} }
Project.populate(newProject, Project.populate(
newProject,
{ path: 'user', select: 'username' }, { path: 'user', select: 'username' },
(innerErr, newProjectWithUser) => { (innerErr, newProjectWithUser) => {
if (innerErr) { if (innerErr) {
@ -28,7 +29,8 @@ export function createProject(req, res) {
return; return;
} }
res.json(newProjectWithUser); res.json(newProjectWithUser);
}); }
);
}); });
} }
@ -42,13 +44,15 @@ export function updateProject(req, res) {
// res.status(409).send({ success: false, message: 'Attempted to save stale version of project.' }); // res.status(409).send({ success: false, message: 'Attempted to save stale version of project.' });
// return; // return;
// } // }
Project.findByIdAndUpdate(req.params.project_id, Project.findByIdAndUpdate(
req.params.project_id,
{ {
$set: req.body $set: req.body
}, },
{ {
new: true new: true
}) }
)
.populate('user', 'username') .populate('user', 'username')
.exec((updateProjectErr, updatedProject) => { .exec((updateProjectErr, updatedProject) => {
if (updateProjectErr) { if (updateProjectErr) {
@ -100,8 +104,7 @@ export function getProject(req, res) {
} }
function deleteFilesFromS3(files) { function deleteFilesFromS3(files) {
deleteObjectsFromS3( deleteObjectsFromS3(files.filter((file) => {
files.filter((file) => {
if (file.url) { if (file.url) {
if (!process.env.S3_DATE || (process.env.S3_DATE && moment(process.env.S3_DATE) < moment(file.createdAt))) { if (!process.env.S3_DATE || (process.env.S3_DATE && moment(process.env.S3_DATE) < moment(file.createdAt))) {
return true; return true;

View file

@ -16,10 +16,12 @@ const random = (done) => {
}; };
export function findUserByUsername(username, cb) { export function findUserByUsername(username, cb) {
User.findOne({ username }, User.findOne(
{ username },
(err, user) => { (err, user) => {
cb(user); cb(user);
}); }
);
} }
const EMAIL_VERIFY_TOKEN_EXPIRY_TIME = Date.now() + (3600000 * 24); // 24 hours const EMAIL_VERIFY_TOKEN_EXPIRY_TIME = Date.now() + (3600000 * 24); // 24 hours
@ -35,7 +37,8 @@ export function createUser(req, res, next) {
verifiedTokenExpires: EMAIL_VERIFY_TOKEN_EXPIRY_TIME, verifiedTokenExpires: EMAIL_VERIFY_TOKEN_EXPIRY_TIME,
}); });
User.findOne({ email: req.body.email }, User.findOne(
{ email: req.body.email },
(err, existingUser) => { (err, existingUser) => {
if (err) { if (err) {
res.status(404).send({ error: err }); res.status(404).send({ error: err });
@ -77,7 +80,8 @@ export function createUser(req, res, next) {
}); });
}); });
}); });
}); }
);
}); });
} }

View file

@ -156,9 +156,7 @@ function getSketchDirectories(sketchRootList) {
}).catch((err) => { }).catch((err) => {
throw err; throw err;
}); });
}) })).then((output) => {
).then((output) => {
const sketchList = []; const sketchList = [];
output.forEach((l) => { output.forEach((l) => {
l.forEach((i) => { l.forEach((i) => {

View file

@ -112,8 +112,10 @@ function getSketchContent(projectsInAllCategories) {
if (noNumberprojectName === 'Instance Mode : Instance Container ') { if (noNumberprojectName === 'Instance Mode : Instance Container ') {
for (let i = 0; i < 4; i += 1) { for (let i = 0; i < 4; i += 1) {
const splitedRes = `${res.split('*/')[1].split('</html>')[i]}</html>\n`; const splitedRes = `${res.split('*/')[1].split('</html>')[i]}</html>\n`;
project.sketchContent = splitedRes.replace('p5.js', project.sketchContent = splitedRes.replace(
'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.min.js'); 'p5.js',
'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.min.js'
);
} }
} else { } else {
project.sketchContent = res; project.sketchContent = res;

View file

@ -12,9 +12,7 @@ export function resolvePathToFile(filePath, files) {
let foundChild = false; let foundChild = false;
const childFiles = currentFile.children.map(childFileId => const childFiles = currentFile.children.map(childFileId =>
files.find(file => files.find(file =>
file._id.valueOf().toString() === childFileId.valueOf() file._id.valueOf().toString() === childFileId.valueOf()));
)
);
childFiles.some((childFile) => { childFiles.some((childFile) => {
if (childFile.name === filePathSegment) { if (childFile.name === filePathSegment) {
currentFile = childFile; currentFile = childFile;

View file

@ -100,10 +100,14 @@ export function get404Sketch(callback) {
htmlFile = html.join('</head>'); htmlFile = html.join('</head>');
// Fix links to assets // Fix links to assets
htmlFile = htmlFile.replace(/'assets/g, htmlFile = htmlFile.replace(
"'https://rawgit.com/processing/p5.js-website/master/dist/assets/examples/assets/"); /'assets/g,
htmlFile = htmlFile.replace(/"assets/g, "'https://rawgit.com/processing/p5.js-website/master/dist/assets/examples/assets/"
'"https://rawgit.com/processing/p5.js-website/master/dist/assets/examples/assets/'); );
htmlFile = htmlFile.replace(
/"assets/g,
'"https://rawgit.com/processing/p5.js-website/master/dist/assets/examples/assets/'
);
// Change canvas size // Change canvas size
htmlFile = htmlFile.replace(/createCanvas\(\d+, ?\d+/g, instanceMode ? htmlFile = htmlFile.replace(/createCanvas\(\d+, ?\d+/g, instanceMode ?