Skip to content
Permalink
Browse files

test(initializer): add test for custom initializer

  • Loading branch information
MarshallOfSound committed Dec 30, 2016
1 parent 9e6ddfa commit 0dc62307b5672b3f057dbbad7bb78d9627c53623
@@ -1,4 +1,4 @@
import { spawn } from 'child_process';
import { execSync, spawn } from 'child_process';
import fs from 'fs-promise';
import os from 'os';
import path from 'path';
@@ -76,6 +76,40 @@ describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => {
forLintingMethod('airbnb');
forLintingMethod('standard');

describe('init (with custom templater)', () => {
let dir;

before(async () => {
dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}`);
dirID += 1;
await fs.remove(dir);
execSync('npm link', {
cwd: path.resolve(__dirname, 'fixture/custom_init'),
});
await pSpawn(['init', dir, '--template=dummy']);
});

it('should create dot files correctly', async () => {
expect(await fs.exists(dir), 'the target dir should have been created').to.equal(true);
expect(await fs.exists(path.resolve(dir, '.bar')), 'the .bar file should exist').to.equal(true);
});

it('should create deep files correctly', async () => {
expect(await fs.exists(path.resolve(dir, 'src/foo.js')), 'the src/foo.js file should exist').to.equal(true);
});

describe('lint', () => {
it('should initially pass the linting process', () => pSpawn(['lint', dir]));
});

after(async () => {
await fs.remove(dir);
execSync('npm unlink', {
cwd: path.resolve(__dirname, 'fixture/custom_init'),
});
});
});

describe('after init', () => {
let dir;

@@ -0,0 +1,8 @@
const path = require('path');

module.exports = {
dependencies: ['react'],
devDependencies: ['react-dom'],
templateDirectory: path.resolve(__dirname, './tmpl'),
postCopy: (initDir, ora, lintStyle) => {}, // eslint-disable-line
};
@@ -0,0 +1,12 @@
{
"name": "electron-forge-template-dummy",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron-forge start"
},
"keywords": [],
"author": "",
"license": "MIT"
}
No changes.
No changes.

0 comments on commit 0dc6230

Please sign in to comment.
You can’t perform that action at this time.