This repository was archived by the owner on Oct 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 1818#include < cctype>
1919#include < vector>
2020#include < algorithm>
21+ #include < stdlib.h>
2122#include < sys/stat.h>
2223#include " file.hpp"
2324#include " context.hpp"
@@ -49,6 +50,15 @@ inline static std::string wstring_to_string(const std::wstring &wstr)
4950# endif
5051#endif
5152
53+ #ifdef _WASM
54+ inline static std::string get_cwd_from_env ()
55+ {
56+ char * value = getenv (" PWD" );
57+ if (!value) return " (unreachable)" ;
58+ return value;
59+ }
60+ #endif
61+
5262namespace Sass {
5363 namespace File {
5464
@@ -57,10 +67,10 @@ namespace Sass {
5767 // always with trailing slash
5868 std::string get_cwd ()
5969 {
60- const size_t wd_len = 4096 ;
6170 #ifdef _WASM
62- std::string cwd = " / " ;
71+ std::string cwd = get_cwd_from_env () ;
6372 #else
73+ const size_t wd_len = 4096 ;
6474 #ifndef _WIN32
6575 char wd[wd_len];
6676 char * pwd = getcwd (wd, wd_len);
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ async function init() {
1515 { "wasi_unstable" : wrapper . exports }
1616 ) ;
1717 host . args = [ wasmPath , ...process . argv . slice ( 2 ) ] ;
18+ host . env = [ `PWD=${ process . cwd ( ) } ` ] ;
1819 host . memory = sassc . exports . memory ;
1920 return sassc . exports ;
2021}
Original file line number Diff line number Diff line change 11{
22 "name": "sassc-wasi",
3- "version": "0.1.0 ",
3+ "version": "0.1.1 ",
44 "description": "",
55 "main": "index.js",
66 "scripts": {
You can’t perform that action at this time.
0 commit comments