8000 refacto: extract WSL check fron symfony-cli/console package by tucksaun · Pull Request #568 · symfony-cli/symfony-cli · GitHub
[go: up one dir, main page]

Skip to content

refacto: extract WSL check fron symfony-cli/console package #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func init() {
}

func InitAppFunc(c *console.Context) error {
checkWSL()

envs.ComputeDockerUserAgent(c.App.Name, c.App.Version)

psh, err := platformsh.Get()
Expand Down
26 changes: 26 additions & 0 deletions commands/wsl_others.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//go:build !windows
// +build !windows

/*
* Copyright (c) 2021-present Fabien Potencier <fabien@symfony.com>
*
* This file is part of Symfony CLI project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package commands

func checkWSL() {
}
41 changes: 41 additions & 0 deletions commands/wsl_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2021-present Fabien Potencier <fabien@symfony.com>
*
* This file is part of Symfony CLI project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package commands

import (
"os"

"github.com/symfony-cli/terminal"
)

func checkWSL() {
if fi, err := os.Stat("/proc/version"); fi == nil || err != nil {
return
}

ui := terminal.SymfonyStyle(terminal.Stdout, terminal.Stdin)
ui.Error("Wrong binary for WSL")
terminal.Println(`You are trying to run the Windows version of the Symfony CLI on WSL (Linux).
You must use the Linux version to use the Symfony CLI on WSL.

Download it at <href=https://symfony.com/download>https://symfony.com/download</>
`)
os.Exit(1)
}
0