Skip to content

Commit a272a6a

Browse files
author
Kelly Selden
committed
support scoped projects using --directory
1 parent f9b7193 commit a272a6a

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/get-start-and-end-commands.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,17 @@ async function isDefaultAddonBlueprint(blueprint) {
8989

9090
function getArgs({
9191
projectName,
92+
directoryName,
9293
blueprint
9394
}) {
9495
let args = [];
9596

9697
if (blueprint.isBaseBlueprint) {
9798
args.push('new');
9899
args.push(projectName);
100+
if (directoryName !== projectName) {
101+
args.push(`-dir=${directoryName}`);
102+
}
99103
args.push('-sg');
100104
} else {
101105
args.push('init');
@@ -156,7 +160,7 @@ function runEmberRemotely({
156160

157161
if (isCustomBlueprint) {
158162
args = ['ember-cli', ...args];
159-
// args = ['-p', 'github:ember-cli/ember-cli#cfb9780', 'ember', 'new', projectName, '-sn', '-sg', '-b', `${blueprint.packageName}@${blueprint.version}`];
163+
// args = ['-p', 'github:ember-cli/ember-cli#cfb9780', 'ember', 'new', projectName, `-dir=${directoryName}, '-sg', -sn', '-b', `${blueprint.packageName}@${blueprint.version}`];
160164
} else {
161165
args = ['-p', `ember-cli@${blueprint.version}`, 'ember', ...args];
162166
}
@@ -174,7 +178,10 @@ function createProject(runEmber) {
174178
}
175179
}) => {
176180
return async function createProject(cwd) {
177-
let projectRoot = path.join(cwd, projectName);
181+
// remove scope
182+
let directoryName = projectName.replace(/^@.+\//, '');
183+
184+
let projectRoot = path.join(cwd, directoryName);
178185

179186
async function _runEmber(blueprint) {
180187
let _cwd = cwd;
@@ -185,6 +192,7 @@ function createProject(runEmber) {
185192

186193
let args = getArgs({
187194
projectName,
195+
directoryName,
188196
blueprint
189197
});
190198

test/unit/get-start-and-end-commands-test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ describe(_getStartAndEndCommands, function() {
775775
function getArgs(options) {
776776
return _getArgs({
777777
projectName,
778+
directoryName: projectName,
778779
...options
779780
});
780781
}
@@ -816,6 +817,26 @@ describe(_getStartAndEndCommands, function() {
816817
]);
817818
});
818819

820+
it('works for scoped project', function() {
821+
let blueprint = loadDefaultBlueprint(['welcome']);
822+
823+
let args = getArgs({
824+
projectName: `@my-scope/${projectName}`,
825+
blueprint
826+
});
827+
828+
expect(args).to.deep.equal([
829+
'new',
830+
`@my-scope/${projectName}`,
831+
`-dir=${projectName}`,
832+
'-sg',
833+
'-sn',
834+
'-sb',
835+
'-b',
836+
'app'
837+
]);
838+
});
839+
819840
it('works for custom base blueprint', function() {
820841
let blueprint = loadSafeBlueprint({
821842
path: '/path/to/my-blueprint',

0 commit comments

Comments
 (0)