Skip to content
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

eslint config gets linked or copied depending on where it comes from #40

Merged
merged 5 commits into from
Aug 20, 2016
Merged
Changes from 1 commit
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
28 changes: 28 additions & 0 deletions cli/actions/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,33 @@ module.exports = (program) => {
}
};


// Create an eslint.json in the user's base directory
const createEsLintLink = () => {
const tmpEsLint = path.join(tmpDir, 'eslint.json');
const linkedPath = path.join(userRootPath, 'eslint.json');

// Backup esLint if it exists
if(shell.test('-f', linkedPath)) {
const eslintBackup = path.join(userRootPath, `eslint-${Date.now()}-bak.json`);
shell.exec(`mv ${linkedPath} ${eslintBackup} `);
logger.task(`Backed up current eslint file to: ${eslintBackup}`);
}

// Copy over starter-kyt esLint
if (shell.test('-f', tmpEsLint)) {
if (shell.cp(tmpEsLint, linkedPath).code === 0 ) {
logger.task('Copied esLint config from starter-kyt');
}
} else {
// Create a symbolic link from our local eslint
const esLintPath = path.join(userRootPath, 'node_modules/kyt/eslint.json');
if (shell.ln('-s', esLintPath, linkedPath).code === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symlink needs to be relative, see #44

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do thanks!

logger.task('Linked esLint config');
}
}
};

// Creates a symbolic link from our local
// .editorconfig to the user's base directory.
const createEditorconfigLink = () => {
Expand Down Expand Up @@ -189,6 +216,7 @@ module.exports = (program) => {
updateUserPackageJSON();
installUserDependencies();
createBabelrcLink();
createEsLintLink();
createEditorconfigLink();
createKytConfig();
createPrototypeFile();
Expand Down