Skip to content

Commit

Permalink
[cli] default to pingy.json, instead of .pingy.json (Closes #57)
Browse files Browse the repository at this point in the history
.pingy.json is still supported for existing sites.
  • Loading branch information
davej committed Oct 10, 2017
1 parent 9a131e2 commit b5e4780
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
18 changes: 5 additions & 13 deletions packages/cli/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const scaffold = require('./scaffold');
const renderLastInit = require('./renderLastInit');

const pkgJsonPath = path.join(process.cwd(), 'package.json');
const pingyJsonPath = path.join(process.cwd(), '.pingy.json');
const dotPingyJsonPath = path.join(process.cwd(), '.pingy.json');
const pingyJsonPath = path.join(process.cwd(), 'pingy.json');
const pkgJsonExists = fs.existsSync(pkgJsonPath);
const pingyJsonExists = fs.existsSync(pingyJsonPath);
const pingyJsonExists = fs.existsSync(pingyJsonPath) || fs.existsSync(dotPingyJsonPath);

const requiredLastInitProps = ['html', 'scripts', 'styles'];
const createChoices = type => [type, ...compilerMap[type].map(x => x.name)];
Expand Down Expand Up @@ -75,7 +76,7 @@ function prompt(options) {
name: 'resume',
default: false,
message:
'Looks like you have run `pingy init` already. Pingy has detected a .pingy.json and package.json in your project, do you want to continue anyway?',
'Looks like you have run `pingy init` already. Pingy has detected a pingy.json and package.json in your project, do you want to continue anyway?',
}
])
.then(answers => resolve(answers.resume));
Expand Down Expand Up @@ -105,20 +106,11 @@ function prompt(options) {
.then((resume) => {
if (global.repeatLastInit) return processAnswers(options)(lastInit);
if (resume) return inquirer.prompt(stage1).then(processAnswers(options));
return null;
});
}

function init(options) {
// if (args.length > 0) {
// return processAnswers(
// {
// html: args.html || 'HTML',
// scripts: args.scripts || 'JS',
// styles: args.styles || 'CSS',
// },
// true
// );
// }
return prompt(options);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/init/updatePkgScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const path = require('path');
const dotPingyTmpl = require('./dotPingyTmpl');

function createDotPingy(name) {
const filename = '.pingy.json';
const filename = 'pingy.json';
const spinner = ora(`Creating ${filename}`).start();
try {
fs.writeFileSync(path.join(process.cwd(), filename), dotPingyTmpl(name), 'utf8');
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/pingyJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const chalk = require('chalk');
const findUp = require('find-up');

function getPingyJson() {
const jsonPath = findUp.sync(['.pingy.json', '.pingy']);
const jsonPath = findUp.sync(['pingy.json', '.pingy.json']);
if (!jsonPath) {
console.log(
chalk.red(
`${chalk.bold('File not found')}: .pingy.json.\nPlease create it or run \`pingy init\`.`
`${chalk.bold('File not found')}: pingy.json.\nPlease create it or run \`pingy init\`.`
)
);
return false;
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/test/1-test-simple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ before(function (done) {
});

describe('cli simple', function cli() {
const pingyJsonPath = path.join(projectPath, '.pingy.json');
const pingyJsonPath = path.join(projectPath, 'pingy.json');
const indexHtml = path.join(projectPath, 'index.html');
const scripts = path.join(projectPath, 'scripts', 'main.js');
const styles = path.join(projectPath, 'styles', 'main.css');
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('cli simple', function cli() {
fs.unlinkSync(styles);
} catch (e) {}
});
it('should create .pingy.json and scaffold using init command', function() {
it('should create pingy.json and scaffold using init command', function() {
const spawned = spawn('node', ['../../cli.js', 'init', '--ask'], {
cwd: projectPath,
});
Expand Down Expand Up @@ -399,7 +399,7 @@ describe('cli simple', function cli() {
fs.unlinkSync(styles);
} catch (e) {}
});
it('should create .pingy.json and scaffold using init command', function() {
it('should create pingy.json and scaffold using init command', function() {
const spawned = spawn('node', ['../../cli.js', 'init'], {
cwd: projectPath,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/test/2-test-advanced.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ before(function (done) {
});

describe('cli advanced', function cli() {
const pingyJsonPath = path.join(projectPath, '.pingy.json');
const pingyJsonPath = path.join(projectPath, 'pingy.json');
const indexHtml = path.join(projectPath, 'index.pug');
const scripts = path.join(projectPath, 'scripts', 'main.babel.js');
const styles = path.join(projectPath, 'styles', 'main.scss');
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('cli advanced', function cli() {
};

describe('init', function() {
it('should create .pingy.json and scaffold using init command', function() {
it('should create pingy.json and scaffold using init command', function() {
const spawnedInit = spawn('node', ['../../cli.js', 'init', '--global-pingy'], {
cwd: projectPath,
});
Expand Down

0 comments on commit b5e4780

Please # to comment.