本文整理汇总了TypeScript中ember-cli-string-utils.classify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript classify函数的具体用法?TypeScript classify怎么用?TypeScript classify使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了classify函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
afterInstall: function(options: any) {
if (options.dryRun) {
return;
}
const returns: Array<any> = [];
const className = stringUtils.classify(`${options.entity.name}Directive`);
const fileName = stringUtils.dasherize(`${options.entity.name}.directive`);
const fullGeneratePath = path.join(this.project.root, this.generatePath);
const moduleDir = path.parse(this.pathToModule).dir;
const relativeDir = path.relative(moduleDir, fullGeneratePath);
const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;
if (!options.skipImport) {
returns.push(
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
.then((change: any) => change.apply(NodeHost))
.then((result: any) => {
if (options.export) {
return astUtils.addExportToModule(this.pathToModule, className, importPath)
.then((change: any) => change.apply(NodeHost));
}
return result;
}));
this._writeStatusToUI(chalk.yellow,
'update',
path.relative(this.project.root, this.pathToModule));
}
return Promise.all(returns);
}
示例2: function
locals: function(options: any) {
this.styleExt = options.style === 'stylus' ? 'styl' : options.style;
this.version = require(path.resolve(__dirname, '../../package.json')).version;
// set this.tests to opposite of skipTest options,
// meaning if tests are being skipped then the default.spec.BLUEPRINT will be false
this.tests = options.skipTests ? false : true;
// Split/join with / not path.sep as reference to typings require forward slashes.
const relativeRootPath = options.sourceDir.split('/').map(() => '..').join('/');
const fullAppName = (stringUtils.dasherize(options.entity.name) as string)
.replace(/-(.)/g, (_, l) => ' ' + l.toUpperCase())
.replace(/^./, (l) => l.toUpperCase());
return {
htmlComponentName: stringUtils.dasherize(options.entity.name),
jsComponentName: stringUtils.classify(options.entity.name),
fullAppName: fullAppName,
version: this.version,
sourceDir: options.sourceDir,
prefix: options.prefix,
styleExt: this.styleExt,
relativeRootPath: relativeRootPath,
routing: options.routing,
inlineStyle: options.inlineStyle,
inlineTemplate: options.inlineTemplate,
ng4: options.ng4,
tests: this.tests
};
},
示例3: function
afterInstall: function (options: any) {
const appConfig = getAppFromConfig(this.options.app);
if (options.prefix && appConfig.prefix && appConfig.prefix !== options.prefix) {
console.log(chalk.yellow(oneLine`You are using different prefix from app,
you might get lint errors. Please update "tslint.json" accordingly.`));
}
const returns: Array<any> = [];
const className = stringUtils.classify(`${options.entity.name}Component`);
const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
const normalizeRelativeDir = componentDir.startsWith('.') ? componentDir : `./${componentDir}`;
const importPath = componentDir ? `${normalizeRelativeDir}/${fileName}` : `./${fileName}`;
if (!options.skipImport) {
if (options.dryRun) {
this._writeStatusToUI(chalk.yellow,
'update',
path.relative(this.project.root, this.pathToModule));
return;
}
let preChange: any;
try {
preChange = fs.readFileSync(this.pathToModule, 'utf8');
} catch (err) {
if (err.code === 'EISDIR') {
throw 'Module specified should be a file, not a directory';
} else {
throw err;
}
}
returns.push(
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
.then((change: any) => change.apply(NodeHost))
.then((result: any) => {
if (options.export) {
return astUtils.addExportToModule(this.pathToModule, className, importPath)
.then((change: any) => change.apply(NodeHost));
}
return result;
})
.then(() => {
const postChange = fs.readFileSync(this.pathToModule, 'utf8');
let moduleStatus = 'update';
if (postChange === preChange) {
moduleStatus = 'identical';
}
this._writeStatusToUI(chalk.yellow,
moduleStatus,
path.relative(this.project.root, this.pathToModule));
this.addModifiedFile(this.pathToModule);
}));
}
return Promise.all(returns);
}
示例4: require
let commandMap = commandFiles.reduce((acc: any, curr: string) => {
let classifiedName = stringUtils.classify(curr);
let defaultImport = require(`./${curr}`).default;
acc[classifiedName] = defaultImport;
return acc;
}, {});
示例5: function
afterInstall: function (options: any) {
const returns: Array<any> = [];
const className = stringUtils.classify(`${options.entity.name}Component`);
const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;
if (!options.skipImport) {
if (options.dryRun) {
this._writeStatusToUI(chalk.yellow,
'update',
path.relative(this.project.root, this.pathToModule));
return;
}
let preChange: any;
try {
preChange = fs.readFileSync(this.pathToModule, 'utf8');
} catch (err) {
if (err.code === 'EISDIR') {
throw 'Module specified should be a file, not a directory';
} else {
throw err;
}
}
returns.push(
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
.then((change: any) => change.apply(NodeHost))
.then((result: any) => {
if (options.export) {
return astUtils.addExportToModule(this.pathToModule, className, importPath)
.then((change: any) => change.apply(NodeHost));
}
return result;
})
.then(() => {
const postChange = fs.readFileSync(this.pathToModule, 'utf8');
let moduleStatus = 'update';
if (postChange === preChange) {
moduleStatus = 'identical';
}
this._writeStatusToUI(chalk.yellow,
moduleStatus,
path.relative(this.project.root, this.pathToModule));
}));
}
return Promise.all(returns);
}
示例6: afterInstall
return this.generatePath;
}
};
},
afterInstall(options: any) {
const returns: Array<any> = [];
if (!this.pathToModule) {
const warningMessage = oneLine`
Module is generated but not provided,
it must be provided to be used
`;
this._writeStatusToUI(chalk.yellow, 'WARNING', warningMessage);
} else {
let className = stringUtils.classify(`${options.entity.name}Module`);
let fileName = stringUtils.dasherize(`${options.entity.name}.module`);
if (options.routing) {
className = stringUtils.classify(`${options.entity.name}RoutingModule`);
fileName = stringUtils.dasherize(`${options.entity.name}-routing.module`);
}
const fullGeneratePath = path.join(this.project.root, this.generatePath);
const moduleDir = path.parse(this.pathToModule).dir;
const relativeDir = path.relative(moduleDir, fullGeneratePath);
const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;
returns.push(
astUtils.addImportToModule(this.pathToModule, className, importPath)
.then((change: any) => change.apply(NodeHost)));
this._writeStatusToUI(chalk.yellow,
'update',
path.relative(this.project.root, this.pathToModule));
示例7: afterInstall
return dir;
}
};
},
afterInstall(options: any) {
const returns: Array<any> = [];
if (!this.pathToModule) {
const warningMessage = oneLine`
Guard is generated but not provided,
it must be provided to be used
`;
this._writeStatusToUI(chalk.yellow, 'WARNING', warningMessage);
} else {
const className = stringUtils.classify(`${options.entity.name}Guard`);
const fileName = stringUtils.dasherize(`${options.entity.name}.guard`);
const fullGeneratePath = path.join(this.project.root, this.generatePath);
const moduleDir = path.parse(this.pathToModule).dir;
const relativeDir = path.relative(moduleDir, fullGeneratePath);
const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;
returns.push(
astUtils.addProviderToModule(this.pathToModule, className, importPath)
.then((change: any) => change.apply(NodeHost)));
this._writeStatusToUI(chalk.yellow,
'update',
path.relative(this.project.root, this.pathToModule));
}
return Promise.all(returns);
}
示例8: afterInstall
return dir;
}
};
},
afterInstall(options: any) {
const returns: Array<any> = [];
if (!this.pathToModule) {
const warningMessage = oneLine`
Service is generated but not provided,
it must be provided to be used
`;
this._writeStatusToUI(chalk.yellow, 'WARNING', warningMessage);
} else {
const className = stringUtils.classify(`${options.entity.name}Service`);
const fileName = stringUtils.dasherize(`${options.entity.name}.service`);
const fullGeneratePath = path.join(this.project.root, this.generatePath);
const moduleDir = path.parse(this.pathToModule).dir;
const relativeDir = path.relative(moduleDir, fullGeneratePath);
const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;
returns.push(
astUtils.addProviderToModule(this.pathToModule, className, importPath)
.then((change: any) => change.apply(NodeHost)));
this._writeStatusToUI(chalk.yellow,
'update',
path.relative(this.project.root, this.pathToModule));
}
return Promise.all(returns);
}