mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 02:54:21 +08:00
34 lines
913 B
TypeScript
34 lines
913 B
TypeScript
import * as path from 'path';
|
|
import {writeFile, readFile} from 'fs-extra';
|
|
import { ng } from './ng';
|
|
import { setup, teardown } from './tmp';
|
|
|
|
export { ng };
|
|
|
|
export function setupProject() {
|
|
beforeEach((done) => {
|
|
spyOn(console, 'error');
|
|
|
|
setup('./tmp')
|
|
.then(() => process.chdir('./tmp'))
|
|
.then(() => ng(['new', 'foo', '--skip-install']))
|
|
.then(() => addAppToProject())
|
|
.then(done, done.fail);
|
|
}, 10000);
|
|
|
|
afterEach((done) => {
|
|
teardown('./tmp').then(done, done.fail);
|
|
});
|
|
}
|
|
|
|
function addAppToProject(): Promise<any> {
|
|
const cliJson = path.join(path.join(process.cwd()), '.angular-cli.json');
|
|
return readFile(cliJson, 'utf-8').then(content => {
|
|
const json = JSON.parse(content);
|
|
json.apps.push(({name: 'other', root: 'other/src', appRoot: ''}));
|
|
return json;
|
|
}).then(json => {
|
|
return writeFile(cliJson, JSON.stringify(json, null, 2))
|
|
});
|
|
}
|