@nestjs/cli
Advanced tools
Comparing version 1.7.0 to 1.7.4
@@ -8,2 +8,3 @@ "use strict"; | ||
const module_path_solver_1 = require("../../module-path-solver/module.path-solver"); | ||
const path = require("path"); | ||
describe('ModuleFinder', () => { | ||
@@ -37,3 +38,3 @@ let sandbox; | ||
.then(filename => { | ||
chai_1.expect(filename).to.be.equal('src/app/app.module.ts'); | ||
chai_1.expect(filename).to.be.equal(path.normalize('src/app/app.module.ts')); | ||
}); | ||
@@ -45,3 +46,3 @@ }); | ||
.then(filename => { | ||
chai_1.expect(filename).to.be.equal('src/app/modules/module1/module1.module.ts'); | ||
chai_1.expect(filename).to.be.equal(path.normalize('src/app/modules/module1/module1.module.ts')); | ||
}); | ||
@@ -48,0 +49,0 @@ }); |
@@ -6,3 +6,3 @@ "use strict"; | ||
constructor() { | ||
this.ROOT_PATH = 'src/app'; | ||
this.ROOT_PATH = path.normalize('src/app'); | ||
this.DEFAULT_MODULE_NAME = 'app'; | ||
@@ -9,0 +9,0 @@ } |
@@ -5,2 +5,3 @@ "use strict"; | ||
const chai_1 = require("chai"); | ||
const path = require("path"); | ||
describe('ModulePathSolver', () => { | ||
@@ -12,13 +13,13 @@ let solver; | ||
const moduleName = 'app'; | ||
chai_1.expect(solver.resolve(moduleName)).to.be.equal('src/app'); | ||
chai_1.expect(solver.resolve(moduleName)).to.be.equal(path.normalize('src/app')); | ||
}); | ||
it('should return the app sub module path', () => { | ||
const moduleName = 'moduleName'; | ||
chai_1.expect(solver.resolve(moduleName)).to.be.equal(`src/app/modules/moduleName`); | ||
chai_1.expect(solver.resolve(moduleName)).to.be.equal(path.normalize('src/app/modules/moduleName')); | ||
}); | ||
it('should return the sub module of app sub-module path', () => { | ||
const moduleName = 'moduleName1/moduleName2/moduleName3'; | ||
chai_1.expect(solver.resolve(moduleName)).to.be.equal(`src/app/modules/moduleName1/modules/moduleName2/modules/moduleName3`); | ||
const moduleName = path.normalize('moduleName1/moduleName2/moduleName3'); | ||
chai_1.expect(solver.resolve(moduleName)).to.be.equal(path.normalize('src/app/modules/moduleName1/modules/moduleName2/modules/moduleName3')); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,4 @@ export declare class StringUtils { | ||
private static computeSeparator(expression); | ||
private static isDashSeparator(expression); | ||
private static isPathSeparator(expression); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path = require("path"); | ||
const os = require("os"); | ||
class StringUtils { | ||
@@ -15,8 +16,17 @@ static capitalize(expression) { | ||
static computeSeparator(expression) { | ||
if (new RegExp('-').test(expression)) | ||
if (this.isDashSeparator(expression)) | ||
return '-'; | ||
else if (new RegExp(path.sep).test(expression)) | ||
return path.sep; | ||
else if (this.isPathSeparator(expression)) | ||
return os.platform() === 'win32' ? path.win32.sep : path.posix.sep; | ||
} | ||
static isDashSeparator(expression) { | ||
return new RegExp('-').test(expression); | ||
} | ||
static isPathSeparator(expression) { | ||
if (os.platform() === 'win32') | ||
return new RegExp('\\'.concat(path.win32.sep)).test(expression); | ||
else | ||
return new RegExp(path.posix.sep).test(expression); | ||
} | ||
} | ||
exports.StringUtils = StringUtils; |
@@ -37,3 +37,3 @@ "use strict"; | ||
describe('#mkdir()', () => { | ||
const target = 'path/to/target'; | ||
const target = path.normalize('path/to/target'); | ||
let statStub; | ||
@@ -51,9 +51,9 @@ let resolveStub; | ||
sinon.assert.callCount(statStub, 3); | ||
sinon.assert.calledWith(statStub, '/path'); | ||
sinon.assert.calledWith(statStub, '/path/to'); | ||
sinon.assert.calledWith(statStub, '/path/to/target'); | ||
sinon.assert.calledWith(statStub, path.normalize('/path')); | ||
sinon.assert.calledWith(statStub, path.normalize('/path/to')); | ||
sinon.assert.calledWith(statStub, path.normalize('/path/to/target')); | ||
sinon.assert.callCount(mkdirStub, 3); | ||
sinon.assert.calledWith(mkdirStub, '/path'); | ||
sinon.assert.calledWith(mkdirStub, '/path/to'); | ||
sinon.assert.calledWith(mkdirStub, '/path/to/target'); | ||
sinon.assert.calledWith(mkdirStub, path.normalize('/path')); | ||
sinon.assert.calledWith(mkdirStub, path.normalize('/path/to')); | ||
sinon.assert.calledWith(mkdirStub, path.normalize('/path/to/target')); | ||
}); | ||
@@ -60,0 +60,0 @@ }); |
@@ -15,3 +15,3 @@ "use strict"; | ||
const destination = path.resolve(dirname, 'destination.ext'); | ||
chai_1.expect(path_utils_1.PathUtils.relative(origin, destination)).to.be.equal('./destination.ext'); | ||
chai_1.expect(path_utils_1.PathUtils.relative(origin, destination)).to.be.equal('.'.concat(path.join(path.sep, 'destination.ext'))); | ||
}); | ||
@@ -21,5 +21,5 @@ it('should return the relative path with origin in a parent directory', () => { | ||
const destination = path.resolve('path/to/file/sub-dir', 'destination.ext'); | ||
chai_1.expect(path_utils_1.PathUtils.relative(origin, destination)).to.be.equal('./sub-dir/destination.ext'); | ||
chai_1.expect(path_utils_1.PathUtils.relative(origin, destination)).to.be.equal('.'.concat(path.join(path.sep, '/sub-dir/destination.ext'))); | ||
}); | ||
}); | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const string_utils_1 = require("../string.utils"); | ||
const chai_1 = require("chai"); | ||
const string_utils_1 = require("../string.utils"); | ||
const sinon = require("sinon"); | ||
const os = require("os"); | ||
describe('StringUtils', () => { | ||
let sandbox; | ||
beforeEach(() => sandbox = sinon.sandbox.create()); | ||
afterEach(() => sandbox.restore()); | ||
describe('#capitalize()', () => { | ||
@@ -12,6 +17,12 @@ const capitalizeResult = 'PathToName'; | ||
}); | ||
it('should capitalize a path expression', () => { | ||
it('should capitalize a Unix style path expression', () => { | ||
const expression = 'path/to/name'; | ||
sandbox.stub(os, 'platform').callsFake(() => 'notWin32'); | ||
chai_1.expect(string_utils_1.StringUtils.capitalize(expression)).to.be.equal(capitalizeResult); | ||
}); | ||
it('should capitalize a Windows style path expression', () => { | ||
sandbox.stub(os, 'platform').callsFake(() => 'win32'); | ||
const expression = 'path\\\\to\\\\name'; | ||
chai_1.expect(string_utils_1.StringUtils.capitalize(expression)).to.be.equal(capitalizeResult); | ||
}); | ||
it('should capitalize the bridge case expression', () => { | ||
@@ -18,0 +29,0 @@ const expression = 'path-to-name'; |
export declare class NestCliApplication { | ||
static run(): void; | ||
static run(version: string): void; | ||
} |
@@ -8,5 +8,5 @@ "use strict"; | ||
class NestCliApplication { | ||
static run() { | ||
static run(version) { | ||
new caporal_program_1.CaporalProgram() | ||
.version('1.0.0') | ||
.version(version) | ||
.help('Nest.js CLI') | ||
@@ -13,0 +13,0 @@ .declare(program => { |
#!/usr/bin/env node | ||
const packageJson = require('./package.json'); | ||
const cli = require('./bin/nest-cli.application'); | ||
cli.NestCliApplication.run(); | ||
cli.NestCliApplication.run(packageJson.version); |
{ | ||
"name": "@nestjs/cli", | ||
"version": "1.7.0", | ||
"version": "1.7.4", | ||
"license": "MIT", | ||
@@ -14,8 +14,10 @@ "publishConfig": { | ||
"build:src": "tsc", | ||
"build:assets": "cp -R src/assets bin/assets", | ||
"clean": "rm -rf bin/* && rm -rf coverage/*", | ||
"build:assets": "node scripts/copy.script.js src/assets bin/assets", | ||
"clean": "node scripts/clean.script.js bin/* && node scripts/clean.script.js coverage/*", | ||
"clean:build": "npm run -s clean && npm run -s build", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"prepare": "npm run clean:build", | ||
"test": "nyc --require ts-node/register mocha src/**/*.spec.ts --reporter spec" | ||
"test": "npm run -s test:src && npm run -s test:scripts", | ||
"test:src": "nyc mocha src/**/*.spec.ts --require ts-node/register --reporter spec", | ||
"test:scripts": "mocha scripts/**/*.spec.ts --require ts-node/register --reporter spec" | ||
}, | ||
@@ -22,0 +24,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
197171
4384