#Viewing Command output

1 messages · Page 1 of 1 (latest)

upper mulch
#

Is there a way to see the output from a given command?

Using modules, I have a func that looks like

  @func()
  async prettier(source: Directory) {
    return await dag
      .container()
      .from('node:20')
      .withDirectory('/src/', source)
      .withWorkdir('/src')
      .withExec(['npx', 'prettier', '.', '--list-different'])
      .stderr()
  }

The command is current exiting with 1 (which is expected), however It doesn't show the full output.

This is what shows up

  ✘ Container.stderr: String! 1.7s
    ✘ exec docker-entrypoint.sh npx prettier . --list-different 1.7s
    ┃ dagger/src/prettier.ts                                                                                                                          
    ┃ npm notice                                                                                                                                      
    ┃ npm notice New minor version of npm available! 10.2.4 -> 10.5.0                                                                                 
    ┃ npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.0>                                                                         
    ┃ npm notice Run `npm install -g npm@10.5.0` to update!                                                                                           
    ┃ npm notice                                                                                                                                      

Error: response from query: input: motionDagger.prettier call function "prettier": process "tsx --no-deprecation --tsconfig /src/dagger/tsconfig.json /src/dagger/src/__dagger.entrypoint.ts" did not complete successfully: exit code: 1

I do see it writing the output as its executing, however the output is constantly cleared.

hoary hill
upper mulch
#

stdout didn't show it either ... i had that first

#

it looks like its just showing the last few lines as that dagger/src/prettier.ts is part of the output that I'm looking for

upper mulch
#

ok... so if I remove the .stdout / .stderr() then it does re-print the output to the terminal

✘ Container.sync: ContainerID! 1.7s
  ✘ exec docker-entrypoint.sh npx prettier . --list-different 1.7s
  ┃ npm notice New minor version of npm available! 10.2.4 -> 10.5.0                                                                           
  ┃ npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.0>                                                                   
  ┃ npm notice Run `npm install -g npm@10.5.0` to update!                                                                                     
  ┃ npm notice                                                                                                                                

Error: response from query: input: container.from.withDirectory.withWorkdir.withExec.sync process "docker-entrypoint.sh npx prettier . --list-different" did not complete successfully: exit code: 1

Stdout:
dagger/sdk/api/client.gen.ts
... (removed for brevity)
dagger/sdk/provisioning/index.ts
dagger/sdk/README.md
Stderr:
npm WARN exec The following package was not found and will be installed: prettier@3.2.5
npm notice 
npm notice New minor version of npm available! 10.2.4 -> 10.5.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.0>
npm notice Run `npm install -g npm@10.5.0` to update!
npm notice
#

In the success case however it doesn't print anything

❯ dagger call prettier --source=.
Container evaluated. Use "dagger call prettier --help" to see available sub-commands.

If I just run the command by itself I get

❯ npx prettier "**/src/**/*.*" --check
Checking formatting...
All matched files use Prettier code style!

I guess my question, is what is the 'proper' way to see the output of a dagger pipeline ?

quiet flicker
#

@upper mulch You should just be able to add stdout to the end of the dagger call (e.g. dagger call prettier --source=. stdout), and as long as your function returns a container (so have the last method be withExec in your example) you'll get the stdout from the container