change demos to typescript and WidthType disparity
This commit is contained in:
@ -1,33 +0,0 @@
|
||||
var prompt = require('prompt');
|
||||
var shelljs = require('shelljs');
|
||||
var fs = require('fs');
|
||||
|
||||
console.log('What demo do you wish to run? (Enter a number)');
|
||||
|
||||
var schema = {
|
||||
properties: {
|
||||
number: {
|
||||
pattern: /^[0-9]+$/,
|
||||
message: 'Please enter a number.',
|
||||
required: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
prompt.start();
|
||||
|
||||
prompt.get(schema, function (err, result) {
|
||||
var demoNumber = result.number;
|
||||
var filePath = `./demo/demo${demoNumber}.ts`;
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
console.error(`demo${demoNumber} does not exist: ${filePath}`);
|
||||
return;
|
||||
}
|
||||
console.log(`Running demo ${demoNumber}`);
|
||||
if (shelljs.exec(`npm run ts-node -- ${filePath}`).code === 0) {
|
||||
console.log("Document created successfully");
|
||||
} else {
|
||||
console.error('Something went wrong with the demo');
|
||||
}
|
||||
});
|
34
demo/index.ts
Normal file
34
demo/index.ts
Normal file
@ -0,0 +1,34 @@
|
||||
// tslint:disable:no-console
|
||||
import * as fs from "fs";
|
||||
import * as prompt from "prompt";
|
||||
import * as shelljs from "shelljs";
|
||||
|
||||
console.log("What demo do you wish to run? (Enter a number)");
|
||||
|
||||
const schema = {
|
||||
properties: {
|
||||
number: {
|
||||
pattern: /^[0-9]+$/,
|
||||
message: "Please enter a number.",
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
prompt.start();
|
||||
|
||||
prompt.get(schema, (_, result) => {
|
||||
const demoNumber = result.number;
|
||||
const filePath = `./demo/demo${demoNumber}.ts`;
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
console.error(`demo${demoNumber} does not exist: ${filePath}`);
|
||||
return;
|
||||
}
|
||||
console.log(`Running demo ${demoNumber}`);
|
||||
if (shelljs.exec(`npm run ts-node -- ${filePath}`).code === 0) {
|
||||
console.log("Document created successfully");
|
||||
} else {
|
||||
console.error("Something went wrong with the demo");
|
||||
}
|
||||
});
|
@ -13,7 +13,7 @@
|
||||
"tsc": "rimraf ./build && tsc -p .",
|
||||
"webpack": "rimraf ./build && webpack",
|
||||
"build.web": "webpack --config webpack.web.config.js",
|
||||
"demo": "npm run build && node ./demo",
|
||||
"demo": "npm run build && npm run ts-node ./demo",
|
||||
"typedoc": "typedoc src/index.ts",
|
||||
"style": "prettier -l \"src/**/*.ts\"",
|
||||
"style.fix": "prettier \"src/**/*.ts\" --write",
|
||||
|
@ -4,6 +4,7 @@ import { expect } from "chai";
|
||||
import { Formatter } from "../../export/formatter";
|
||||
import { Paragraph } from "../paragraph";
|
||||
import { Table } from "./";
|
||||
import { WidthType } from "./table-cell";
|
||||
|
||||
const DEFAULT_TABLE_PROPERTIES = {
|
||||
"w:tblBorders": [
|
||||
@ -174,7 +175,7 @@ describe("Table", () => {
|
||||
|
||||
describe("#setWidth", () => {
|
||||
it("sets the preferred width on the table", () => {
|
||||
const table = new Table(2, 2).setWidth("pct", 1000);
|
||||
const table = new Table(2, 2).setWidth(WidthType.PERCENTAGE, 1000);
|
||||
const tree = new Formatter().format(table);
|
||||
expect(tree)
|
||||
.to.have.property("w:tbl")
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
import { IXmlableObject, XmlComponent } from "file/xml-components";
|
||||
import { Paragraph } from "../paragraph";
|
||||
import { TableGrid } from "./grid";
|
||||
import { TableProperties, WidthTypes } from "./properties";
|
||||
import { TableProperties } from "./properties";
|
||||
|
||||
export class Table extends XmlComponent {
|
||||
private readonly properties: TableProperties;
|
||||
@ -67,7 +67,7 @@ export class Table extends XmlComponent {
|
||||
return this.getRow(row).getCell(col);
|
||||
}
|
||||
|
||||
public setWidth(type: WidthTypes, width: number | string): Table {
|
||||
public setWidth(type: WidthType, width: number | string): Table {
|
||||
this.properties.setWidth(type, width);
|
||||
return this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user