ic-mops 0.17.3 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.js CHANGED
@@ -186,7 +186,7 @@ program
186
186
  program
187
187
  .command('test [filter]')
188
188
  .description('Run tests')
189
- .option('--watch', 'Enable watch mode')
189
+ .option('-w, --watch', 'Enable watch mode')
190
190
  .action(async (filter, options) => {
191
191
  await test(filter, options);
192
192
  });
package/commands/docs.js CHANGED
@@ -13,8 +13,8 @@ let moDoc;
13
13
 
14
14
  export async function docs({silent} = {}) {
15
15
  let rootDir = getRootDir();
16
- let docsDir = path.join(rootDir, '.mops/_docs');
17
- let docsDirRelative = path.relative(process.cwd(), path.join(rootDir, '.mops/_docs'));
16
+ let docsDir = path.join(rootDir, '.mops/.docs');
17
+ let docsDirRelative = path.relative(process.cwd(), docsDir);
18
18
 
19
19
  del.sync([docsDir], {force: true});
20
20
 
package/commands/mmf1.js CHANGED
@@ -81,7 +81,7 @@ export class MMF1 {
81
81
  }
82
82
  else if (status === 'fail') {
83
83
  this.failed++;
84
- this._log(' '.repeat(this.stack.length * 2), chalk.red('×'), name);
84
+ this._log(' '.repeat(this.stack.length * 2), chalk.red(''), name);
85
85
  }
86
86
  else if (status === 'skip') {
87
87
  this.skipped++;
@@ -183,7 +183,7 @@ export async function publish({noDocs} = {}) {
183
183
  files = globbySync([...files, ...defaultFiles]);
184
184
 
185
185
  // generate docs
186
- let docsFile = path.join(rootDir, '.mops/_docs/docs.tgz');
186
+ let docsFile = path.join(rootDir, '.mops/.docs/docs.tgz');
187
187
  if (!noDocs) {
188
188
  await docs({silent: true});
189
189
  if (fs.existsSync(docsFile)) {
@@ -260,6 +260,8 @@ export async function publish({noDocs} = {}) {
260
260
  }
261
261
  });
262
262
 
263
+ fs.rmSync(path.join(rootDir, '.mops/.docs'), {force: true, recursive: true});
264
+
263
265
  // finish
264
266
  progress();
265
267
  let res = await actor.finishPublish(puiblishingId);
package/commands/test.js CHANGED
@@ -39,7 +39,10 @@ export async function test(filter = '', {watch = false} = {}) {
39
39
  console.log(chalk.gray((`Press ${chalk.gray('Ctrl+C')} to exit.`)));
40
40
  }, 200);
41
41
 
42
- let watcher = chokidar.watch(path.join(rootDir, '**/*.mo'), {
42
+ let watcher = chokidar.watch([
43
+ path.join(rootDir, '**/*.mo'),
44
+ path.join(rootDir, 'mops.toml'),
45
+ ], {
43
46
  ignored: ignore,
44
47
  ignoreInitial: true,
45
48
  });
@@ -139,7 +142,7 @@ export async function runAll(filter = '') {
139
142
  skipped += mmf.skipped;
140
143
 
141
144
  i++ && console.log('-'.repeat(50));
142
- console.log(`Running ${chalk.gray(file)} ${wasiMode ? chalk.gray('(wasi)') : ''}`);
145
+ console.log(`Running ${chalk.gray(path.relative(rootDir, file))} ${wasiMode ? chalk.gray('(wasi)') : ''}`);
143
146
  mmf.flush();
144
147
  });
145
148
 
@@ -182,9 +185,28 @@ function pipeMMF(proc, mmf) {
182
185
  // stderr
183
186
  proc.stderr.on('data', (data) => {
184
187
  let text = data.toString().trim();
185
- // change absolute file path to relative
186
- // change :line:col-line:col to :line:col to work in vscode
187
- text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (m0, m1, m2, m3) => `${absToRel(m1)}:${m2}:${m3}`);
188
+ let failedLine = '';
189
+ text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (m0, m1, m2, m3) => {
190
+ // change absolute file path to relative
191
+ // change :line:col-line:col to :line:col to work in vscode
192
+ let res = `${absToRel(m1)}:${m2}:${m3}`;
193
+ // show failed line
194
+ let content = fs.readFileSync(m1);
195
+ let lines = content.toString().split('\n');
196
+ failedLine += chalk.dim`\n ...`;
197
+ if (m2 - 2 >= 0) {
198
+ failedLine += chalk.dim`\n ${+m2 - 1}\t| ${lines[m2 - 2].replaceAll('\t', ' ')}`;
199
+ }
200
+ failedLine += `\n${chalk.redBright`->`} ${m2}\t| ${lines[m2 - 1].replaceAll('\t', ' ')}`;
201
+ if (lines.length > +m2) {
202
+ failedLine += chalk.dim`\n ${+m2 + 1}\t| ${lines[m2].replaceAll('\t', ' ')}`;
203
+ }
204
+ failedLine += chalk.dim`\n ...`;
205
+ return res;
206
+ });
207
+ if (failedLine) {
208
+ text += failedLine;
209
+ }
188
210
  mmf.fail(text);
189
211
  });
190
212
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.17.3",
3
+ "version": "0.18.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "cli.js"